-
Notifications
You must be signed in to change notification settings - Fork 1
Unrestricted Bot Channel
Yiping Su edited this page Apr 13, 2020
·
1 revision
As of the latest build, .config
requires you to provide a channel ID of where Isabelle should process bot commands. Commands posted in other channels will not be processed.
To move processing restrictions, go to isabellebot/bot.go
and find the following function:
// processCmd attemps to process any string that is prefixed with bot notifier
//
// Valid commands will be run while invalid commands will be ignored
//
// Example bot commands:
//
// ?search
//
// ?search help
func (b *Bot) processCmd(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.ChannelID != b.BotCh {
// Command must be posted in bot channel; if not, command won't be processed
return
}
cmds := regexp.MustCompile("\\s+").Split(m.Content[len(b.Prefix):], -1)
trim := strings.TrimPrefix(cmds[0], b.Prefix)
res := b.find(trim)
if res == nil {
// Command not found
return
}
var commands []string
for key := range b.Commands {
commands = append(commands, key)
}
ci := cmd.CommandInfo{
AdminRole: b.AdminRole,
Ses: s,
Msg: m,
Service: b.Service,
ListingID: b.Listing,
BotChID: b.BotCh,
AppID: b.App,
Prefix: b.Prefix,
CmdName: trim,
CmdOps: cmds,
CmdList: commands,
}
// Run command
res.Cmd(ci)
}
Remove:
if m.ChannelID != b.BotCh {
// Command must be posted in bot channel; if not, command won't be processed
return
}
Removing the snippet above will tell Isabelle to process commands whenever a new message is created.