make the commandPrefix a config value

This commit is contained in:
lyx0 2022-08-11 23:34:00 +02:00
parent 28b318dc92
commit b832ec63b6
3 changed files with 7 additions and 3 deletions

View file

@ -47,9 +47,9 @@ func (app *Application) handleCommand(message twitch.PrivateMessage) {
app.Logger.Infow("Command received",
// "message", message,
"message.Message", message.Message,
"message.Channel", target,
"user level", userLevel,
"message.Message", message.Message,
"commandName", commandName,
"cmdParams", cmdParams,
"msgLen", msgLen,

View file

@ -33,7 +33,8 @@ func main() {
cfg.twitchOauth = os.Getenv("TWITCH_OAUTH")
tc := twitch.NewClient(cfg.twitchUsername, cfg.twitchOauth)
// Environment
// Basic configuration
cfg.commandPrefix = "()"
cfg.environment = "Development"
// Database
@ -77,8 +78,10 @@ func main() {
// Message was shorter than our prefix is therefore it's irrelevant for us.
if len(message.Message) >= 2 {
// This bots prefix is "()" configured above at `cfg.commandPrefix`,
// Check if the first 2 characters of the mesage were our prefix.
if message.Message[:2] == "()" {
// if they were forward the message to the command handler.
if message.Message[:2] == cfg.commandPrefix {
app.handleCommand(message)
return
}

View file

@ -19,6 +19,7 @@ var (
type config struct {
twitchUsername string
twitchOauth string
commandPrefix string
environment string
db struct {
dsn string