mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
make the commandPrefix a config value
This commit is contained in:
parent
28b318dc92
commit
b832ec63b6
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ var (
|
|||
type config struct {
|
||||
twitchUsername string
|
||||
twitchOauth string
|
||||
commandPrefix string
|
||||
environment string
|
||||
db struct {
|
||||
dsn string
|
||||
|
|
Loading…
Reference in a new issue