Add downstream self WHO and WHOIS support

This commit is contained in:
delthas 2020-03-22 00:46:56 +01:00 committed by Simon Ser
parent a958a01446
commit 9486d657c5
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 36 additions and 2 deletions

View File

@ -960,6 +960,21 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
// TODO: support WHO masks
entity := msg.Params[0]
if entity == dc.nick {
// TODO: support AWAY (H/G) in self WHO reply
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_WHOREPLY,
Params: []string{dc.nick, "*", dc.username, dc.hostname, dc.srv.Hostname, dc.nick, "H", "0 " + dc.realname},
})
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_ENDOFWHO,
Params: []string{dc.nick, dc.nick, "End of /WHO list"},
})
return nil
}
uc, upstreamName, err := dc.unmarshalEntity(entity)
if err != nil {
return err
@ -997,6 +1012,25 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
mask = mask[:i]
}
if mask == dc.nick {
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_WHOISUSER,
Params: []string{dc.nick, dc.nick, dc.username, dc.hostname, "*", dc.realname},
})
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_WHOISSERVER,
Params: []string{dc.nick, dc.nick, dc.srv.Hostname, "soju"},
})
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_ENDOFWHOIS,
Params: []string{dc.nick, dc.nick, "End of /WHOIS list"},
})
return nil
}
// TODO: support WHOIS masks
uc, upstreamNick, err := dc.unmarshalEntity(mask)
if err != nil {

View File

@ -758,7 +758,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_ENDOFWHO,
Params: []string{dc.nick, name, "End of WHO list"},
Params: []string{dc.nick, name, "End of /WHO list"},
})
})
case irc.RPL_WHOISUSER:
@ -852,7 +852,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_ENDOFWHOIS,
Params: []string{dc.nick, nick, "End of WHOIS list"},
Params: []string{dc.nick, nick, "End of /WHOIS list"},
})
})
case "PRIVMSG":