mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 13:59:44 +01:00
Show users in WHO queries if they are friends, i.e. they share a channel.
This commit is contained in:
parent
1ef41d6020
commit
b3cfcc1289
@ -1022,6 +1022,21 @@ func (client *Client) ModeString() (str string) {
|
|||||||
return "+" + client.modes.String()
|
return "+" + client.modes.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsFriend() returns true if the given otherClient shares a channel with this client, or if they are the same user.
|
||||||
|
func (client *Client) IsFriend(otherClient *Client) bool {
|
||||||
|
if client == otherClient {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, channel := range client.Channels() {
|
||||||
|
if channel.hasClient(otherClient) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Friends refers to clients that share a channel with this client.
|
// Friends refers to clients that share a channel with this client.
|
||||||
func (client *Client) Friends(capabs ...caps.Capability) (result map[*Session]bool) {
|
func (client *Client) Friends(capabs ...caps.Capability) (result map[*Session]bool) {
|
||||||
result = make(map[*Session]bool)
|
result = make(map[*Session]bool)
|
||||||
|
@ -2637,7 +2637,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for mclient := range server.clients.FindAll(mask) {
|
for mclient := range server.clients.FindAll(mask) {
|
||||||
if !mclient.HasMode(modes.Invisible) || isOper {
|
if isOper || !mclient.HasMode(modes.Invisible) || mclient.IsFriend(client) {
|
||||||
client.rplWhoReply(nil, mclient, rb)
|
client.rplWhoReply(nil, mclient, rb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user