mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
channel: Send channel NOTICEs properly
This commit is contained in:
parent
7068072292
commit
5eafd2656e
@ -321,6 +321,15 @@ func (channel *Channel) CanSpeak(client *Client) bool {
|
||||
|
||||
// PrivMsg sends a private message to everyone in this channel.
|
||||
func (channel *Channel) PrivMsg(minPrefix *ChannelMode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message string) {
|
||||
channel.sendMessage("PRIVMSG", minPrefix, clientOnlyTags, client, message)
|
||||
}
|
||||
|
||||
// Notice sends a private message to everyone in this channel.
|
||||
func (channel *Channel) Notice(minPrefix *ChannelMode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message string) {
|
||||
channel.sendMessage("NOTICE", minPrefix, clientOnlyTags, client, message)
|
||||
}
|
||||
|
||||
func (channel *Channel) sendMessage(cmd string, minPrefix *ChannelMode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message string) {
|
||||
if !channel.CanSpeak(client) {
|
||||
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
|
||||
return
|
||||
@ -339,9 +348,9 @@ func (channel *Channel) PrivMsg(minPrefix *ChannelMode, clientOnlyTags *map[stri
|
||||
continue
|
||||
}
|
||||
if member.capabilities[MessageTags] {
|
||||
member.SendFromClient(client, clientOnlyTags, client.nickMaskString, "PRIVMSG", channel.name, message)
|
||||
member.SendFromClient(client, clientOnlyTags, client.nickMaskString, cmd, channel.name, message)
|
||||
} else {
|
||||
member.SendFromClient(client, nil, client.nickMaskString, "PRIVMSG", channel.name, message)
|
||||
member.SendFromClient(client, nil, client.nickMaskString, cmd, channel.name, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -455,19 +464,6 @@ func (channel *Channel) applyModeMask(client *Client, mode ChannelMode, op ModeO
|
||||
return false
|
||||
}
|
||||
|
||||
func (channel *Channel) Notice(client *Client, message string) {
|
||||
if !channel.CanSpeak(client) {
|
||||
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel")
|
||||
return
|
||||
}
|
||||
for member := range channel.members {
|
||||
if member == client {
|
||||
continue
|
||||
}
|
||||
member.SendFromClient(client, nil, client.nickMaskString, "NOTICE", channel.name, message)
|
||||
}
|
||||
}
|
||||
|
||||
func (channel *Channel) Quit(client *Client) {
|
||||
channel.members.Remove(client)
|
||||
client.channels.Remove(channel)
|
||||
|
@ -1314,7 +1314,7 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
// errors silently ignored with NOTICE as per RFC
|
||||
continue
|
||||
}
|
||||
channel.PrivMsg(lowestPrefix, clientOnlyTags, client, message)
|
||||
channel.Notice(lowestPrefix, clientOnlyTags, client, message)
|
||||
} else {
|
||||
target, err := CasefoldName(targetString)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user