mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
USERHOST: Clean up a bit, support multiple nicks
This commit is contained in:
parent
b3a54cbb2c
commit
9f6c4363b7
@ -371,8 +371,9 @@ Used in connection registration, sets your username and realname to the given
|
|||||||
values (though your username may also be looked up with Ident).`,
|
values (though your username may also be looked up with Ident).`,
|
||||||
},
|
},
|
||||||
"userhost": {
|
"userhost": {
|
||||||
text: `Show the nick, user and host of a user. Normally only used by the client or in scripts.
|
text: `USERHOST <nickname>{ <nickname>}
|
||||||
Note: if you are not an IRCOp then it will show a cloaked hostname if the user is +x (and it's not yourself). `,
|
|
||||||
|
Shows information about the given users. Takes up to 10 nicknames.`,
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
text: `VERSION [server]
|
text: `VERSION [server]
|
||||||
|
@ -339,7 +339,7 @@ func (server *Server) setISupport() {
|
|||||||
server.isupport.Add("RPCHAN", "E")
|
server.isupport.Add("RPCHAN", "E")
|
||||||
server.isupport.Add("RPUSER", "E")
|
server.isupport.Add("RPUSER", "E")
|
||||||
server.isupport.Add("STATUSMSG", "~&@%+")
|
server.isupport.Add("STATUSMSG", "~&@%+")
|
||||||
server.isupport.Add("TARGMAX", fmt.Sprintf("NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:%s,TAGMSG:%s,NOTICE:%s,MONITOR:", maxTargetsString, maxTargetsString, maxTargetsString))
|
server.isupport.Add("TARGMAX", fmt.Sprintf("NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:%s,TAGMSG:%s,NOTICE:%s,MONITOR:", maxTargetsString, maxTargetsString, maxTargetsString))
|
||||||
server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen))
|
server.isupport.Add("TOPICLEN", strconv.Itoa(server.limits.TopicLen))
|
||||||
|
|
||||||
// account registration
|
// account registration
|
||||||
@ -1851,19 +1851,38 @@ func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
|
|
||||||
// USERHOST <nickname> [<nickname> <nickname> ...]
|
// USERHOST <nickname> [<nickname> <nickname> ...]
|
||||||
func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||||
nickname := msg.Params[0]
|
returnedNicks := make(map[string]bool)
|
||||||
|
|
||||||
casefoldedNickname, err := CasefoldName(nickname)
|
for i, nickname := range msg.Params {
|
||||||
target := server.clients.Get(casefoldedNickname)
|
if i >= 10 {
|
||||||
if err != nil || target == nil {
|
break
|
||||||
client.Send(nil, client.server.name, ERR_NOSUCHNICK, nickname, "No such nick")
|
}
|
||||||
return false
|
|
||||||
|
casefoldedNickname, err := CasefoldName(nickname)
|
||||||
|
target := server.clients.Get(casefoldedNickname)
|
||||||
|
if err != nil || target == nil {
|
||||||
|
client.Send(nil, client.server.name, ERR_NOSUCHNICK, nickname, "No such nick")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if returnedNicks[casefoldedNickname] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// to prevent returning multiple results for a single nick
|
||||||
|
returnedNicks[casefoldedNickname] = true
|
||||||
|
|
||||||
|
var isOper, isAway string
|
||||||
|
|
||||||
|
if target.flags[Operator] {
|
||||||
|
isOper = "*"
|
||||||
|
}
|
||||||
|
if target.flags[Away] {
|
||||||
|
isAway = "-"
|
||||||
|
} else {
|
||||||
|
isAway = "+"
|
||||||
|
}
|
||||||
|
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf("%s%s=%s%s@%s", target.nick, isOper, isAway, target.username, target.hostname))
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.flags[Away] {
|
|
||||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf("%s=-%s@%s", target.nick, target.username, target.hostname))
|
|
||||||
} else {
|
|
||||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf("%s=+%s@%s", target.nick, target.username, target.hostname))
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user