diff options
-rw-r--r-- | connector/irc/irc.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/connector/irc/irc.go b/connector/irc/irc.go index 19e73fc..77388e7 100644 --- a/connector/irc/irc.go +++ b/connector/irc/irc.go @@ -25,6 +25,8 @@ type IRC struct { name string server string conn *girc.Client + + joinedRooms map[string]bool } func (irc *IRC) SetHandler(h Handler) { @@ -95,6 +97,8 @@ func (irc *IRC) Configure(c Configuration) error { client.Handlers.Add(girc.TOPIC, irc.ircTopic) client.Handlers.Add(girc.RPL_TOPIC, irc.ircRplTopic) + irc.joinedRooms = make(map[string]bool) + irc.conn = client go irc.connectLoop(client) @@ -300,6 +304,12 @@ func (irc *IRC) ircConnected(c *girc.Client, e girc.Event) { irc.handler.SystemMessage("Connected to IRC.") irc.timeout = 10 irc.connected = true + + for room, joined := range irc.joinedRooms { + if joined { + irc.conn.Cmd.Join(room) + } + } } func (irc *IRC) ircPrivmsg(c *girc.Client, e girc.Event) { @@ -321,6 +331,7 @@ func (irc *IRC) ircJoin(c *girc.Client, e girc.Event) { room := RoomID(e.Params[0] + "@" + irc.server) if e.Source.Name == irc.nick { irc.handler.Joined(room) + irc.joinedRooms[e.Params[0]] = true } else { user := UserID(e.Source.Name + "@" + irc.server) ev := &Event{ @@ -339,6 +350,7 @@ func (irc *IRC) ircPart(c *girc.Client, e girc.Event) { room := RoomID(e.Params[0] + "@" + irc.server) if e.Source.Name == irc.nick { irc.handler.Left(room) + delete(irc.joinedRooms, e.Params[0]) } else { user := UserID(e.Source.Name + "@" + irc.server) ev := &Event{ |