diff --git a/bridge.go b/bridge.go index 3782a7b..026e07d 100644 --- a/bridge.go +++ b/bridge.go @@ -9,6 +9,13 @@ func forwardChannel(dc *downstreamConn, ch *upstreamChannel) { panic("Tried to forward a partial channel") } + sendTopic(dc, ch) + + // TODO: rpl_topicwhotime + sendNames(dc, ch) +} + +func sendTopic(dc *downstreamConn, ch *upstreamChannel) { downstreamName := dc.marshalChannel(ch.conn, ch.Name) if ch.Topic != "" { @@ -24,9 +31,6 @@ func forwardChannel(dc *downstreamConn, ch *upstreamChannel) { Params: []string{dc.nick, downstreamName, "No topic is set"}, }) } - - // TODO: rpl_topicwhotime - sendNames(dc, ch) } func sendNames(dc *downstreamConn, ch *upstreamChannel) { diff --git a/downstream.go b/downstream.go index 676d1f1..a3accbc 100644 --- a/downstream.go +++ b/downstream.go @@ -1032,6 +1032,33 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { Params: params, }) } + case "TOPIC": + var channel string + if err := parseMessageParams(msg, &channel); err != nil { + return err + } + + uc, upstreamChannel, err := dc.unmarshalEntity(channel) + if err != nil { + return err + } + + if len(msg.Params) > 1 { // setting topic + topic := msg.Params[1] + uc.SendMessage(&irc.Message{ + Command: "TOPIC", + Params: []string{upstreamChannel, topic}, + }) + } else { // getting topic + ch, ok := uc.channels[upstreamChannel] + if !ok { + return ircError{&irc.Message{ + Command: irc.ERR_NOSUCHCHANNEL, + Params: []string{dc.nick, upstreamChannel, "No such channel"}, + }} + } + sendTopic(dc, ch) + } case "NAMES": if len(msg.Params) == 0 { dc.SendMessage(&irc.Message{