Join channels on config change

This commit is contained in:
Knut Ahlers 2020-12-21 01:52:10 +01:00
parent da62d913c8
commit 55b17a635a
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 9 additions and 3 deletions

10
irc.go
View file

@ -59,6 +59,12 @@ func newIRCHandler() (*ircHandler, error) {
func (i ircHandler) Close() error { return i.conn.Close() } 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) { func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
switch m.Command { switch m.Command {
case "001": case "001":
@ -74,9 +80,7 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
}, " "), }, " "),
}, },
}) })
for _, ch := range config.Channels { i.ExecuteJoins(config.Channels)
c.Write(fmt.Sprintf("JOIN #%s", strings.TrimLeft(ch, "#")))
}
case "NOTICE": case "NOTICE":
// NOTICE (Twitch Commands) // NOTICE (Twitch Commands)

View file

@ -105,6 +105,8 @@ func main() {
continue continue
} }
irc.ExecuteJoins(config.Channels)
log.Info("Config file reloaded") log.Info("Config file reloaded")
} }