mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
add whois support for services
This commit is contained in:
parent
cd339281e4
commit
c95ed46949
@ -189,7 +189,7 @@ func (clients *ClientManager) FindAll(userhost string) (set ClientSet) {
|
||||
clients.RLock()
|
||||
defer clients.RUnlock()
|
||||
for _, client := range clients.byNick {
|
||||
if matcher.Match(client.nickMaskCasefolded) {
|
||||
if matcher.Match(client.NickMaskCasefolded()) {
|
||||
set.Add(client)
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,7 @@ func (clients *ClientManager) Find(userhost string) *Client {
|
||||
clients.RLock()
|
||||
defer clients.RUnlock()
|
||||
for _, client := range clients.byNick {
|
||||
if matcher.Match(client.nickMaskCasefolded) {
|
||||
if matcher.Match(client.NickMaskCasefolded()) {
|
||||
matchedClient = client
|
||||
break
|
||||
}
|
||||
|
@ -2478,16 +2478,25 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
||||
return false
|
||||
}
|
||||
|
||||
if client.HasMode(modes.Operator) {
|
||||
masks := strings.Split(masksString, ",")
|
||||
for _, mask := range masks {
|
||||
casefoldedMask, err := Casefold(mask)
|
||||
if err != nil {
|
||||
rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
||||
continue
|
||||
handleService := func(nick string) bool {
|
||||
cfnick, _ := CasefoldName(nick)
|
||||
service, ok := OragonoServices[cfnick]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
matches := server.clients.FindAll(casefoldedMask)
|
||||
if len(matches) == 0 {
|
||||
clientNick := client.Nick()
|
||||
rb.Add(nil, client.server.name, RPL_WHOISUSER, clientNick, service.Name, service.Name, "localhost", "*", fmt.Sprintf(client.t("Network service, for more info /msg %s HELP"), service.Name))
|
||||
// hehe
|
||||
if client.HasMode(modes.TLS) {
|
||||
rb.Add(nil, client.server.name, RPL_WHOISSECURE, clientNick, service.Name, client.t("is using a secure connection"))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if client.HasMode(modes.Operator) {
|
||||
for _, mask := range strings.Split(masksString, ",") {
|
||||
matches := server.clients.FindAll(mask)
|
||||
if len(matches) == 0 && !handleService(mask) {
|
||||
rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
||||
continue
|
||||
}
|
||||
@ -2496,15 +2505,15 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// only get the first request
|
||||
casefoldedMask, err := Casefold(strings.Split(masksString, ",")[0])
|
||||
mclient := server.clients.Get(casefoldedMask)
|
||||
if err != nil || mclient == nil {
|
||||
rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, masksString, client.t("No such nick"))
|
||||
// fall through, ENDOFWHOIS is always sent
|
||||
} else {
|
||||
// only get the first request; also require a nick, not a mask
|
||||
nick := strings.Split(masksString, ",")[0]
|
||||
mclient := server.clients.Get(nick)
|
||||
if mclient != nil {
|
||||
client.getWhoisOf(mclient, rb)
|
||||
} else if !handleService(nick) {
|
||||
rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, masksString, client.t("No such nick"))
|
||||
}
|
||||
// fall through, ENDOFWHOIS is always sent
|
||||
}
|
||||
rb.Add(nil, server.name, RPL_ENDOFWHOIS, client.nick, masksString, client.t("End of /WHOIS list"))
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user