Add downstream TOPIC support
This commit is contained in:
parent
bab26c7a6f
commit
a018f35c42
10
bridge.go
10
bridge.go
@ -9,6 +9,13 @@ func forwardChannel(dc *downstreamConn, ch *upstreamChannel) {
|
|||||||
panic("Tried to forward a partial channel")
|
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)
|
downstreamName := dc.marshalChannel(ch.conn, ch.Name)
|
||||||
|
|
||||||
if ch.Topic != "" {
|
if ch.Topic != "" {
|
||||||
@ -24,9 +31,6 @@ func forwardChannel(dc *downstreamConn, ch *upstreamChannel) {
|
|||||||
Params: []string{dc.nick, downstreamName, "No topic is set"},
|
Params: []string{dc.nick, downstreamName, "No topic is set"},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: rpl_topicwhotime
|
|
||||||
sendNames(dc, ch)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendNames(dc *downstreamConn, ch *upstreamChannel) {
|
func sendNames(dc *downstreamConn, ch *upstreamChannel) {
|
||||||
|
@ -1032,6 +1032,33 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
Params: params,
|
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":
|
case "NAMES":
|
||||||
if len(msg.Params) == 0 {
|
if len(msg.Params) == 0 {
|
||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
|
Loading…
Reference in New Issue
Block a user