diff options
-rw-r--r-- | include/modules.h | 11 | ||||
-rw-r--r-- | src/coremods/core_privmsg.cpp | 9 | ||||
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_ircv3_echomessage.cpp | 7 |
4 files changed, 27 insertions, 1 deletions
diff --git a/include/modules.h b/include/modules.h index 72aa7b4d7..11bf6d55a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -214,7 +214,7 @@ enum Implementation I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick, - I_OnUserPostMessage, I_OnMode, + I_OnUserPostMessage, I_OnUserMessageBlocked, I_OnMode, I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit, I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule, @@ -533,6 +533,15 @@ class CoreExport Module : public classbase, public usecountbase */ virtual void OnUserMessage(User* user, const MessageTarget& target, const MessageDetails& details); + /** Called when a message sent by a user to a channel, a user, or a server glob mask is blocked. + * @param user The user sending the message. + * @param target The target of the message. This can either be a channel, a user, or a server + * glob mask. + * @param details Details about the message such as the message text and type. See the + * MessageDetails class for more information. + */ + virtual void OnUserMessageBlocked(User* user, const MessageTarget& target, const MessageDetails& details); + /** Called after every MODE command sent from a user * Either the usertarget or the chantarget variable contains the target of the modes, * the actual target will have a non-NULL pointer. diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index f1461df5f..6c5b7557e 100644 --- a/src/coremods/core_privmsg.cpp +++ b/src/coremods/core_privmsg.cpp @@ -99,7 +99,10 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para ModResult MOD_RESULT; FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, msgtarget, msgdetails)); if (MOD_RESULT == MOD_RES_DENY) + { + FOREACH_MOD(OnUserMessageBlocked, (user, msgtarget, msgdetails)); return CMD_FAILURE; + } FOREACH_MOD(OnUserMessage, (user, msgtarget, msgdetails)); if (InspIRCd::Match(ServerInstance->Config->ServerName, servername, NULL)) @@ -155,7 +158,10 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para ModResult MOD_RESULT; FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, msgtarget, msgdetails)); if (MOD_RESULT == MOD_RES_DENY) + { + FOREACH_MOD(OnUserMessageBlocked, (user, msgtarget, msgdetails)); return CMD_FAILURE; + } /* Check again, a module may have zapped the input string */ if (msgdetails.text.empty()) @@ -231,7 +237,10 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para ModResult MOD_RESULT; FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, msgtarget, msgdetails)); if (MOD_RESULT == MOD_RES_DENY) + { + FOREACH_MOD(OnUserMessageBlocked, (user, msgtarget, msgdetails)); return CMD_FAILURE; + } FOREACH_MOD(OnUserMessage, (user, msgtarget, msgdetails)); diff --git a/src/modules.cpp b/src/modules.cpp index 5f8439c44..9359cac37 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -113,6 +113,7 @@ ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { Detach ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { DetachEvent(I_OnPassCompare); return MOD_RES_PASSTHRU; } void Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); } void Module::OnUserPostMessage(User*, const MessageTarget&, const MessageDetails&) { DetachEvent(I_OnUserPostMessage); } +void Module::OnUserMessageBlocked(User*, const MessageTarget&, const MessageDetails&) { DetachEvent(I_OnUserMessageBlocked); } void Module::OnUserInvite(User*, User*, Channel*, time_t, unsigned int, CUList&) { DetachEvent(I_OnUserInvite); } void Module::OnPostTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPostTopicChange); } void Module::OnDecodeMetaData(Extensible*, const std::string&, const std::string&) { DetachEvent(I_OnDecodeMetaData); } diff --git a/src/modules/m_ircv3_echomessage.cpp b/src/modules/m_ircv3_echomessage.cpp index c2818700f..056b02194 100644 --- a/src/modules/m_ircv3_echomessage.cpp +++ b/src/modules/m_ircv3_echomessage.cpp @@ -61,6 +61,13 @@ class ModuleIRCv3EchoMessage : public Module user->WriteFrom(user, msg); } + void OnUserMessageBlocked(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE + { + // Prevent spammers from knowing that their spam was blocked. + if (details.echooriginal) + OnUserPostMessage(user, target, details); + } + Version GetVersion() CXX11_OVERRIDE { return Version("Provides the echo-message IRCv3.2 extension", VF_VENDOR); |