mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-28 23:19:30 +01:00
USERHOST command
This commit is contained in:
parent
9e65d9b87e
commit
f3c9c2b4b5
@ -12,6 +12,7 @@ New release of Oragono!
|
||||
### Security
|
||||
|
||||
### Added
|
||||
* Added `USERHOST` command (thanks @vegax87).
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -238,6 +238,10 @@ var Commands = map[string]Command{
|
||||
usablePreReg: true,
|
||||
minParams: 4,
|
||||
},
|
||||
"USERHOST": {
|
||||
handler: userhostHandler,
|
||||
minParams: 1,
|
||||
},
|
||||
"VERSION": {
|
||||
handler: versionHandler,
|
||||
minParams: 0,
|
||||
|
@ -370,6 +370,12 @@ For example:
|
||||
Used in connection registration, sets your username and realname to the given
|
||||
values (though your username may also be looked up with Ident).`,
|
||||
},
|
||||
|
||||
"userhost": {
|
||||
text: `Show the nick, user and host of a user. Normally only used by the client or in scripts.
|
||||
Note: if you are not an IRCOp then it will show a cloaked hostname if the user is +x (and it's not yourself). `,
|
||||
},
|
||||
|
||||
"version": {
|
||||
text: `VERSION [server]
|
||||
|
||||
|
@ -1848,3 +1848,21 @@ func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf("I have %d clients and %d servers", totalcount, 1))
|
||||
return false
|
||||
}
|
||||
|
||||
func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
nickname := msg.Params[0]
|
||||
|
||||
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 target.flags[Away] {
|
||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf(strings.TrimSpace("%s =- %s @ %s"), target.nick, target.username, target.hostname))
|
||||
} else {
|
||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf(strings.TrimSpace("%s =+ %s @ %s"), target.nick, target.username, target.hostname))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user