3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00

bug fix: SAMODE should list other users' modes

This commit is contained in:
Shivaram Lingamneni 2017-10-22 23:07:21 -04:00
parent fa83ccd82b
commit 240f121e5e

View File

@ -329,6 +329,8 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
nickname, err := CasefoldName(msg.Params[0]) nickname, err := CasefoldName(msg.Params[0])
target := server.clients.Get(nickname) target := server.clients.Get(nickname)
targetNick := target.getNick()
hasPrivs := client == target || msg.Command == "SAMODE"
if err != nil || target == nil { if err != nil || target == nil {
if len(msg.Params[0]) > 0 { if len(msg.Params[0]) > 0 {
@ -337,7 +339,7 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
return false return false
} }
if client != target && msg.Command != "SAMODE" { if !hasPrivs {
if len(msg.Params) > 1 { if len(msg.Params) > 1 {
client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, "Can't change modes for other users") client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, "Can't change modes for other users")
} else { } else {
@ -367,13 +369,13 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
if len(applied) > 0 { if len(applied) > 0 {
client.Send(nil, client.nickMaskString, "MODE", target.nick, applied.String()) client.Send(nil, client.nickMaskString, "MODE", targetNick, applied.String())
} else if client == target { } else if hasPrivs {
client.Send(nil, target.nickMaskString, RPL_UMODEIS, target.nick, target.ModeString()) client.Send(nil, target.nickMaskString, RPL_UMODEIS, targetNick, target.ModeString())
if client.flags[LocalOperator] || client.flags[Operator] { if client.flags[LocalOperator] || client.flags[Operator] {
masks := server.snomasks.String(client) masks := server.snomasks.String(client)
if 0 < len(masks) { if 0 < len(masks) {
client.Send(nil, target.nickMaskString, RPL_SNOMASKIS, target.nick, masks, "Server notice masks") client.Send(nil, target.nickMaskString, RPL_SNOMASKIS, targetNick, masks, "Server notice masks")
} }
} }
} }