mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 08:10:08 +00:00
Join channels on config change
This commit is contained in:
parent
da62d913c8
commit
55b17a635a
2 changed files with 9 additions and 3 deletions
10
irc.go
10
irc.go
|
@ -59,6 +59,12 @@ func newIRCHandler() (*ircHandler, error) {
|
|||
|
||||
func (i ircHandler) Close() error { return i.conn.Close() }
|
||||
|
||||
func (i ircHandler) ExecuteJoins(channels []string) {
|
||||
for _, ch := range channels {
|
||||
i.c.Write(fmt.Sprintf("JOIN #%s", strings.TrimLeft(ch, "#")))
|
||||
}
|
||||
}
|
||||
|
||||
func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
|
||||
switch m.Command {
|
||||
case "001":
|
||||
|
@ -74,9 +80,7 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
|
|||
}, " "),
|
||||
},
|
||||
})
|
||||
for _, ch := range config.Channels {
|
||||
c.Write(fmt.Sprintf("JOIN #%s", strings.TrimLeft(ch, "#")))
|
||||
}
|
||||
i.ExecuteJoins(config.Channels)
|
||||
|
||||
case "NOTICE":
|
||||
// NOTICE (Twitch Commands)
|
||||
|
|
2
main.go
2
main.go
|
@ -105,6 +105,8 @@ func main() {
|
|||
continue
|
||||
}
|
||||
|
||||
irc.ExecuteJoins(config.Channels)
|
||||
|
||||
log.Info("Config file reloaded")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue