WHOIS support (needs testing)
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
f1051fbfc2
commit
7b2ab6642b
2
TODO.txt
2
TODO.txt
@ -15,8 +15,6 @@ WISHLIST
|
|||||||
|
|
||||||
- automatic markdown bold/italic formatting
|
- automatic markdown bold/italic formatting
|
||||||
|
|
||||||
- support WHOIS
|
|
||||||
|
|
||||||
- support USERIP/KILL/KICK for ops
|
- support USERIP/KILL/KICK for ops
|
||||||
|
|
||||||
- use CTCP chat to support irc-special characters in chat messages (colon, newline)
|
- use CTCP chat to support irc-special characters in chat messages (colon, newline)
|
||||||
|
36
server.go
36
server.go
@ -657,6 +657,35 @@ func (s *Server) handleJoinedCommand(command string, args []string) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
case "WHOIS":
|
||||||
|
if len(args) < 1 {
|
||||||
|
s.reply(errMoreArgs)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// WHOIS [target] nick[,nick2[,nick...]]
|
||||||
|
nicklist := args[0] // Assume WHOIS ${nick} only,
|
||||||
|
if len(args) >= 2 {
|
||||||
|
nicklist = args[1] // It was WHOIS ${target} ${nick} instead
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, targetnick := range strings.Split(nicklist, ",") {
|
||||||
|
// tell the client something about it
|
||||||
|
// The protocol does ostensibly support wildcard WHOIS, but we don't (yet)
|
||||||
|
s.upstream.Users(func(u *map[string]libnmdc.UserInfo) error {
|
||||||
|
for nick, nickinfo := range *u {
|
||||||
|
if nick == targetnick {
|
||||||
|
s.reply(rplWhoisUser, nick, nickinfo.Description+" <"+nickinfo.ClientVersion+">")
|
||||||
|
if nickinfo.IsOperator {
|
||||||
|
s.reply(rplWhoisOperator, nick)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
s.reply(rplEndOfWhois)
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
s.reply(errUnknownCommand, command)
|
s.reply(errUnknownCommand, command)
|
||||||
}
|
}
|
||||||
@ -815,6 +844,13 @@ func (s *Server) reply(code replyCode, args ...string) {
|
|||||||
case rplPong:
|
case rplPong:
|
||||||
s.writeClient(fmt.Sprintf(":%s PONG %s %s", s.name, s.clientNick(), args[0]))
|
s.writeClient(fmt.Sprintf(":%s PONG %s %s", s.name, s.clientNick(), args[0]))
|
||||||
|
|
||||||
|
case rplWhoisUser:
|
||||||
|
s.writeClient(fmt.Sprintf(":%s 311 %s %s %s * :%s", s.name, args[0], args[0], args[0], args[1])) // caller should supply nick,description
|
||||||
|
case rplWhoisOperator:
|
||||||
|
s.writeClient(fmt.Sprintf(":%s 313 %s :is an IRC operator", s.name, args[0]))
|
||||||
|
case rplEndOfWhois:
|
||||||
|
s.writeClient(fmt.Sprintf(":%s 318 :End of WHOIS list", s.name))
|
||||||
|
|
||||||
case errMoreArgs:
|
case errMoreArgs:
|
||||||
s.writeClient(fmt.Sprintf(":%s 461 %s :Not enough params", s.name, s.clientNick()))
|
s.writeClient(fmt.Sprintf(":%s 461 %s :Not enough params", s.name, s.clientNick()))
|
||||||
case errNoNick:
|
case errNoNick:
|
||||||
|
@ -56,6 +56,9 @@ const (
|
|||||||
rplMOTD
|
rplMOTD
|
||||||
rplEndOfMOTD
|
rplEndOfMOTD
|
||||||
rplPong
|
rplPong
|
||||||
|
rplWhoisUser
|
||||||
|
rplWhoisOperator
|
||||||
|
rplEndOfWhois
|
||||||
errMoreArgs
|
errMoreArgs
|
||||||
errNoNick
|
errNoNick
|
||||||
errInvalidNick
|
errInvalidNick
|
||||||
|
Loading…
Reference in New Issue
Block a user