Go-SyncBot is a lightweight and extensible bot for CyTube project.
Designed to enhance the functionality and user experience on CyTube via custom chat commands.
- Golang 1.21
- Docker 19+ (optional)
Clone or download the repository from https://github.com/uninstallgentoo/go-syncbot.
Go-SyncBot uses a configuration file to define CyTube server settings. The default configuration file is named config.example.yaml.
cp config.example.yaml config.yaml
Adjust the values in the configuration file to match your setup. Example config.yaml:
server:
host: "cytu.be"
secure: true
channel:
name: "test"
password: ""
user:
name: "admin"
password: "admin"
database:
path: "storages/bot.db"
docker compose up
Apply migrations to the database using the following command:
# install goose as a database migration tool
go install github.com/pressly/goose/v3/cmd/goose@latest
goose -dir ./migrations sqlite3 ./storages/bot.db up
Navigate to the repository directory and build the executable using the following command:
go mod download
go build -o syncbot main.go
Once the configuration is set, run the syncbot executable to run bot:
./syncbot
- Create a new Go module in the
commands
directory. - There's a simple interface to implement your own command. Pointer to the command struct in the
ExecFunc
signature allows you to use any attribute of it, such as Processors, Config and Cache.
echo.go content:
var Echo = &command.Command{
Name: "echo", // command name that will be used in the chat
Description: "display text that is passed as arguments",
Rank: 1, // minimum required user rank to execute the command
ExecFunc: func(args []string, cmd *command.Command) (models.CommandResult, error) {
return models.NewCommandResult(
models.NewChatMessage(strings.Join(args, " ")),
), nil
},
}
- Register a new command in the
main.go
.
commandHandler.RegisterCommands(
commands.Dice,
commands.Alert,
commands.Stat,
commands.Pick,
commands.MagicBall,
commands.Who,
commands.Weather,
commands.Echo,
)
- Run the bot and send
!echo
in the CyTube channel chat.
Go-SyncBot is open-source and distributed under the MIT License. Feel free to use, modify, and distribute it as per the terms of the license.