AWAY: Only dispatch AWAY when cap-notify is used

This commit is contained in:
Daniel Oaks 2016-10-13 18:08:08 +10:00
parent e807f3ca04
commit 0eebd6273c
2 changed files with 8 additions and 2 deletions

View File

@ -255,11 +255,17 @@ func (c *Client) Id() string {
} }
// 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() ClientSet { func (client *Client) Friends(Capabilities ...Capability) ClientSet {
friends := make(ClientSet) friends := make(ClientSet)
friends.Add(client) friends.Add(client)
for channel := range client.channels { for channel := range client.channels {
for member := range channel.members { for member := range channel.members {
// make sure they have all the required caps
for _, Cap := range Capabilities {
if !member.capabilities[Cap] {
continue
}
}
friends.Add(member) friends.Add(member)
} }
} }

View File

@ -862,7 +862,7 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
client.Send(nil, server.name, "MODE", client.nick, client.nick, modech.String()) client.Send(nil, server.name, "MODE", client.nick, client.nick, modech.String())
// dispatch away-notify // dispatch away-notify
for friend := range client.Friends() { for friend := range client.Friends(AwayNotify) {
if client.flags[Away] { if client.flags[Away] {
friend.SendFromClient(client, nil, client.nickMaskString, "AWAY", client.awayMessage) friend.SendFromClient(client, nil, client.nickMaskString, "AWAY", client.awayMessage)
} else { } else {