From 584312f30805680711557ff6fbe291d2404367fb Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 17 Feb 2020 15:30:01 +0100 Subject: Correctly update room topics (works on irc) --- connector/irc/irc.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'connector/irc') diff --git a/connector/irc/irc.go b/connector/irc/irc.go index 8e5cdb0..b673498 100644 --- a/connector/irc/irc.go +++ b/connector/irc/irc.go @@ -78,7 +78,8 @@ func (irc *IRC) Configure(c Configuration) error { client.Handlers.Add(girc.JOIN, irc.ircJoin) client.Handlers.Add(girc.PART, irc.ircPart) client.Handlers.Add(girc.RPL_NAMREPLY, irc.ircNamreply) - client.Handlers.Add(girc.RPL_TOPIC, irc.ircTopic) + client.Handlers.Add(girc.TOPIC, irc.ircTopic) + client.Handlers.Add(girc.RPL_TOPIC, irc.ircRplTopic) irc.conn = client go irc.connectLoop(client) @@ -131,7 +132,9 @@ func (irc *IRC) SetRoomInfo(roomId RoomID, info *RoomInfo) error { if info.Picture != nil { return fmt.Errorf("Room picture not supported on IRC") } - irc.conn.Cmd.Topic(ch, info.Description) + if info.Topic != "" { + irc.conn.Cmd.Topic(ch, info.Topic) + } return nil } @@ -302,10 +305,18 @@ func (irc *IRC) ircNamreply(c *girc.Client, e girc.Event) { } func (irc *IRC) ircTopic(c *girc.Client, e girc.Event) { + source := UserID(e.Source.Name + "@" + irc.server) + room := RoomID(e.Params[0] + "@" + irc.server) + topic := e.Last() + irc.handler.RoomInfoUpdated(room, source, &RoomInfo{ + Topic: topic, + }) +} + +func (irc *IRC) ircRplTopic(c *girc.Client, e girc.Event) { room := RoomID(e.Params[1] + "@" + irc.server) topic := e.Last() - irc.handler.RoomInfoUpdated(room, &RoomInfo{ - Name: string(room), - Description: topic, + irc.handler.RoomInfoUpdated(room, "", &RoomInfo{ + Topic: topic, }) } -- cgit v1.2.3