diff options
author | Peter Powell <petpow@saberuk.com> | 2018-08-14 23:22:14 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-08-15 08:58:06 +0100 |
commit | c5c5a867d29c98c73e4f9cc67841617c2598a320 (patch) | |
tree | 430cb3cbb9e4bb5547eb5492ad2c9d1214b0fb16 | |
parent | be0c4f6a3c0e65435f211d817270073dce047396 (diff) |
Fix aliases that resolve to messages echoing with echo-message.
Fixes #1459.
-rw-r--r-- | include/message.h | 12 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_chanfilter.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_ircv3_echomessage.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_muteban.cpp | 2 |
6 files changed, 30 insertions, 11 deletions
diff --git a/include/message.h b/include/message.h index 1799e6119..8c7c7592a 100644 --- a/include/message.h +++ b/include/message.h @@ -32,14 +32,17 @@ enum MessageType class CoreExport MessageDetails { public: + /** Whether to echo the message at all. */ + bool echo; + /* Whether to send the original message back to clients with echo-message support. */ - bool echooriginal; + bool echo_original; /** The users who are exempted from receiving this message. */ CUList exemptions; /* The original message as sent by the user. */ - const std::string originaltext; + const std::string original_text; /** IRCv3 message tags sent to the server by the user. */ const ClientProtocol::TagMap tags_in; @@ -54,8 +57,9 @@ class CoreExport MessageDetails const MessageType type; MessageDetails(MessageType mt, const std::string& msg, const ClientProtocol::TagMap& tags) - : echooriginal(false) - , originaltext(msg) + : echo(true) + , echo_original(false) + , original_text(msg) , tags_in(tags) , text(msg) , type(mt) diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 935cb8259..6f27ecc09 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -68,6 +68,9 @@ class ModuleAlias : public Module bool AllowBots; UserModeReference botmode; + // Whether we are actively executing an alias. + bool active; + public: void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { @@ -177,6 +180,15 @@ class ModuleAlias : public Module return MOD_RES_PASSTHRU; } + ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE + { + // Don't echo anything which is caused by an alias. + if (active) + details.echo = false; + + return MOD_RES_PASSTHRU; + } + void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE { if ((target.type != MessageTarget::TYPE_CHANNEL) || (details.type != MSG_PRIVMSG)) @@ -351,7 +363,10 @@ class ModuleAlias : public Module { pars.push_back(token); } + + active = true; ServerInstance->Parser.CallHandler(command, pars, user); + active = false; } void Prioritize() CXX11_OVERRIDE diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index ce6a31a34..903aab33a 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -116,7 +116,7 @@ class ModuleChanFilter : public Module { if (!notifyuser) { - details.echooriginal = true; + details.echo_original = true; return MOD_RES_DENY; } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index fa78e833b..984a88559 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -365,7 +365,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason); } else - details.echooriginal = true; + details.echo_original = true; } else if (f->action == FA_SILENT) { @@ -377,7 +377,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar user->WriteNotice("Your message to "+target+" was blocked: "+f->reason); } else - details.echooriginal = true; + details.echo_original = true; } else if (f->action == FA_KILL) { diff --git a/src/modules/m_ircv3_echomessage.cpp b/src/modules/m_ircv3_echomessage.cpp index 68505a195..f6eae5a00 100644 --- a/src/modules/m_ircv3_echomessage.cpp +++ b/src/modules/m_ircv3_echomessage.cpp @@ -33,13 +33,13 @@ class ModuleIRCv3EchoMessage : public Module void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE { - if (!cap.get(user)) + if (!cap.get(user) || !details.echo) return; // Caps are only set on local users LocalUser* const localuser = static_cast<LocalUser*>(user); - const std::string& text = details.echooriginal ? details.originaltext : details.text; + const std::string& text = details.echo_original ? details.original_text : details.text; if (target.type == MessageTarget::TYPE_USER) { User* destuser = target.Get<User>(); @@ -66,7 +66,7 @@ class ModuleIRCv3EchoMessage : public Module void OnUserMessageBlocked(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE { // Prevent spammers from knowing that their spam was blocked. - if (details.echooriginal) + if (details.echo_original) OnUserPostMessage(user, target, details); } diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp index aebc00462..7698835b1 100644 --- a/src/modules/m_muteban.cpp +++ b/src/modules/m_muteban.cpp @@ -39,7 +39,7 @@ class ModuleQuietBan : public Module bool notifyuser = ServerInstance->Config->ConfValue("muteban")->getBool("notifyuser", true); if (!notifyuser) { - details.echooriginal = true; + details.echo_original = true; return MOD_RES_DENY; } |