From d9db688963d288261d7f1fe052a177815af1af9e Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Sat, 22 Oct 2016 22:29:01 +1000 Subject: [PATCH] Implement echo-message capability --- CHANGELOG.md | 2 +- irc/capability.go | 2 ++ irc/channel.go | 2 +- irc/server.go | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e37ba4..589fbdf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ New release of Oragono! ### Added * Added `REHASH` command. * Added ability to enable and disable SASL. -* Added support for IRCv3 capability [`cap-notify`](http://ircv3.net/specs/extensions/cap-notify-3.2.html). +* Added support for IRCv3 capabilities [`cap-notify`](http://ircv3.net/specs/extensions/cap-notify-3.2.html) and [`echo-message`](http://ircv3.net/specs/extensions/echo-message-3.2.html). ### Changed diff --git a/irc/capability.go b/irc/capability.go index 9671f921..9318f984 100644 --- a/irc/capability.go +++ b/irc/capability.go @@ -18,6 +18,7 @@ const ( AccountNotify Capability = "account-notify" AwayNotify Capability = "away-notify" CapNotify Capability = "cap-notify" + EchoMessage Capability = "echo-message" ExtendedJoin Capability = "extended-join" InviteNotify Capability = "invite-notify" MessageTags Capability = "draft/message-tags" @@ -33,6 +34,7 @@ var ( AccountNotify: true, AwayNotify: true, CapNotify: true, + EchoMessage: true, ExtendedJoin: true, InviteNotify: true, MessageTags: true, diff --git a/irc/channel.go b/irc/channel.go index e38f5024..f936a8b7 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -314,7 +314,7 @@ func (channel *Channel) PrivMsg(clientOnlyTags *map[string]ircmsg.TagValue, clie return } for member := range channel.members { - if member == client { + if member == client && !client.capabilities[EchoMessage] { continue } if member.capabilities[MessageTags] { diff --git a/irc/server.go b/irc/server.go index ff48ab4b..b8a8c3c7 100644 --- a/irc/server.go +++ b/irc/server.go @@ -705,6 +705,9 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool clientOnlyTags = nil } user.SendFromClient(client, clientOnlyTags, client.nickMaskString, "PRIVMSG", user.nick, message) + if client.capabilities[EchoMessage] { + client.SendFromClient(client, clientOnlyTags, client.nickMaskString, "PRIVMSG", user.nick, message) + } if user.flags[Away] { //TODO(dan): possibly implement cooldown of away notifications to users client.Send(nil, server.name, RPL_AWAY, user.nick, user.awayMessage) @@ -1132,6 +1135,9 @@ func noticeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { clientOnlyTags = nil } user.SendFromClient(client, clientOnlyTags, client.nickMaskString, "NOTICE", user.nick, message) + if client.capabilities[EchoMessage] { + client.SendFromClient(client, clientOnlyTags, client.nickMaskString, "NOTICE", user.nick, message) + } } } return false