mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +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()
|
clients.RLock()
|
||||||
defer clients.RUnlock()
|
defer clients.RUnlock()
|
||||||
for _, client := range clients.byNick {
|
for _, client := range clients.byNick {
|
||||||
if matcher.Match(client.nickMaskCasefolded) {
|
if matcher.Match(client.NickMaskCasefolded()) {
|
||||||
set.Add(client)
|
set.Add(client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ func (clients *ClientManager) Find(userhost string) *Client {
|
|||||||
clients.RLock()
|
clients.RLock()
|
||||||
defer clients.RUnlock()
|
defer clients.RUnlock()
|
||||||
for _, client := range clients.byNick {
|
for _, client := range clients.byNick {
|
||||||
if matcher.Match(client.nickMaskCasefolded) {
|
if matcher.Match(client.NickMaskCasefolded()) {
|
||||||
matchedClient = client
|
matchedClient = client
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -2478,16 +2478,25 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.HasMode(modes.Operator) {
|
handleService := func(nick string) bool {
|
||||||
masks := strings.Split(masksString, ",")
|
cfnick, _ := CasefoldName(nick)
|
||||||
for _, mask := range masks {
|
service, ok := OragonoServices[cfnick]
|
||||||
casefoldedMask, err := Casefold(mask)
|
if !ok {
|
||||||
if err != nil {
|
return false
|
||||||
rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
matches := server.clients.FindAll(casefoldedMask)
|
clientNick := client.Nick()
|
||||||
if len(matches) == 0 {
|
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"))
|
rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -2496,15 +2505,15 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// only get the first request
|
// only get the first request; also require a nick, not a mask
|
||||||
casefoldedMask, err := Casefold(strings.Split(masksString, ",")[0])
|
nick := strings.Split(masksString, ",")[0]
|
||||||
mclient := server.clients.Get(casefoldedMask)
|
mclient := server.clients.Get(nick)
|
||||||
if err != nil || mclient == nil {
|
if 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 {
|
|
||||||
client.getWhoisOf(mclient, rb)
|
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"))
|
rb.Add(nil, server.name, RPL_ENDOFWHOIS, client.nick, masksString, client.t("End of /WHOIS list"))
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user