3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-26 22:09:24 +01:00

Merge pull request #489 from slingamn/issue488.1

fix #488
This commit is contained in:
Daniel Oaks 2019-05-15 11:41:50 +10:00 committed by GitHub
commit c2300e3e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1191,8 +1191,9 @@ func isonHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
ison := make([]string, 0, len(msg.Params)) ison := make([]string, 0, len(msg.Params))
for _, nick := range nicks { for _, nick := range nicks {
if iclient := server.clients.Get(nick); iclient != nil { currentNick := server.getCurrentNick(nick)
ison = append(ison, iclient.Nick()) if currentNick != "" {
ison = append(ison, currentNick)
} }
} }
@ -1749,6 +1750,16 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
return false return false
} }
// get the correct capitalization of a nick (if it's online), otherwise return ""
func (server *Server) getCurrentNick(nick string) (result string) {
if service, isService := OragonoServices[strings.ToLower(nick)]; isService {
return service.Name
} else if iclient := server.clients.Get(nick); iclient != nil {
return iclient.Nick()
}
return ""
}
// MONITOR <subcmd> [params...] // MONITOR <subcmd> [params...]
func monitorHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func monitorHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
handler, exists := monitorSubcommands[strings.ToLower(msg.Params[0])] handler, exists := monitorSubcommands[strings.ToLower(msg.Params[0])]
@ -1813,11 +1824,12 @@ func monitorAddHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb
continue continue
} }
currentNick := server.getCurrentNick(target)
// add to online / offline lists // add to online / offline lists
if targetClient := server.clients.Get(casefoldedTarget); targetClient == nil { if currentNick != "" {
offline = append(offline, target) online = append(online, currentNick)
} else { } else {
online = append(online, targetClient.Nick()) offline = append(offline, target)
} }
} }
@ -1845,9 +1857,10 @@ func monitorListHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
var nickList []string var nickList []string
for _, cfnick := range monitorList { for _, cfnick := range monitorList {
replynick := cfnick replynick := cfnick
currentNick := server.getCurrentNick(cfnick)
// report the uncasefolded nick if it's available, i.e., the client is online // report the uncasefolded nick if it's available, i.e., the client is online
if mclient := server.clients.Get(cfnick); mclient != nil { if currentNick != "" {
replynick = mclient.Nick() replynick = currentNick
} }
nickList = append(nickList, replynick) nickList = append(nickList, replynick)
} }
@ -1869,11 +1882,11 @@ func monitorStatusHandler(server *Server, client *Client, msg ircmsg.IrcMessage,
monitorList := server.monitorManager.List(client) monitorList := server.monitorManager.List(client)
for _, name := range monitorList { for _, name := range monitorList {
target := server.clients.Get(name) currentNick := server.getCurrentNick(name)
if target == nil { if currentNick != "" {
offline = append(offline, name) online = append(online, currentNick)
} else { } else {
online = append(online, target.Nick()) offline = append(offline, name)
} }
} }