diff options
author | alex | 2018-10-23 00:15:28 +0100 |
---|---|---|
committer | alex | 2018-10-23 00:15:28 +0100 |
commit | 9120ee3691856275086357d053f1d39ddaa8fa18 (patch) | |
tree | baaa0885c0867df92dc5183c1d1e415868b6734c /wat/bot.go | |
parent | 19716c3afbf5902e208a32215dd1c63ec7c5a9f6 (diff) | |
download | watbot-9120ee3691856275086357d053f1d39ddaa8fa18.tar.gz watbot-9120ee3691856275086357d053f1d39ddaa8fa18.tar.bz2 watbot-9120ee3691856275086357d053f1d39ddaa8fa18.zip |
fixed some bugs, fixed some debug behaviour, changed over to a command -> method map to avoid sending spurious messages
Diffstat (limited to 'wat/bot.go')
-rw-r--r-- | wat/bot.go | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -15,6 +15,12 @@ type WatBot struct { Nick string } +var allowedChannels = []string { + "##wat", + "##test", + "##sweden", +} + func NewWatBot(config *irc.ClientConfig, serverConn *tls.Conn) *WatBot { wat := WatBot{conn:serverConn, Nick:config.Nick} wat.Db = NewWatDb() @@ -42,8 +48,17 @@ func (w *WatBot) Admin(m *irc.Message) bool { return m.Prefix.Host == "tripsit/operator/hibs" } +func (w *WatBot) AllowedChannel(c string) bool { + for _, allowed := range allowedChannels { + if c == allowed { + return true + } + } + return false +} + func (w *WatBot) Msg(m *irc.Message) { - if !strings.Contains(m.Prefix.Host, "tripsit") || (m.Params[0] != "##wat" && m.Params[0] != "##test" && !w.Admin(m)) { + if !strings.Contains(m.Prefix.Host, "tripsit") || (!w.AllowedChannel(m.Params[0]) && !w.Admin(m)) { return } @@ -56,7 +71,7 @@ func (w *WatBot) Msg(m *irc.Message) { } } - if len(args) < 1 && args[0] != "wat" && args[0][0] != '#' { + if len(args) < 1 || (args[0] != "wat" && args[0][0] != '#') { return } if args[0][0] == '#' { |