diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-05-16 16:33:16 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-05-20 23:30:11 +0200 |
commit | 7a67685bcb863b0d4199715e86697fee423596c2 (patch) | |
tree | e9d5d9de3a8ea66b785131012e2a777eaa8004e5 | |
parent | 06a606ea6668d6a5fa506f7de4575eff7c3c8871 (diff) |
Remove OnUserPreNotice and OnUserNotice hooks, add MessageType argument to OnUserMessage and OnUserPreMessage
All modules (except m_nonotice) that perform filtering on messages have common logic for handling PRIVMSGs and NOTICEs and most of them run the exact same code in both cases
27 files changed, 72 insertions, 225 deletions
diff --git a/include/modules.h b/include/modules.h index 72ee2683d..accd9f03a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -359,8 +359,8 @@ enum Implementation I_BEGIN, I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash, I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, - I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick, - I_OnUserMessage, I_OnUserNotice, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, + I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick, + I_OnUserMessage, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops, I_OnAcceptConnection, I_OnUserInit, I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, @@ -645,30 +645,10 @@ class CoreExport Module : public classbase, public usecountbase * @param status The status being used, e.g. PRIVMSG @#chan has status== '@', 0 to send to everyone. * @param exempt_list A list of users not to send to. For channel messages, this will usually contain just the sender. * It will be ignored for private messages. + * @param msgtype The message type, MSG_PRIVMSG for PRIVMSGs, MSG_NOTICE for NOTICEs * @return 1 to deny the message, 0 to allow it */ - virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list); - - /** Called whenever a user is about to NOTICE A user or a channel, before any processing is done. - * Returning any nonzero value from this function stops the process immediately, causing no - * output to be sent to the user by the core. If you do this you must produce your own numerics, - * notices etc. This is useful for modules which may want to filter or redirect messages. - * target_type can be one of TYPE_USER or TYPE_CHANNEL. If the target_type value is a user, - * you must cast dest to a User* otherwise you must cast it to a Channel*, this is the details - * of where the message is destined to be sent. - * You may alter the message text as you wish before relinquishing control to the next module - * in the chain, and if no other modules block the text this altered form of the text will be sent out - * to the user and possibly to other servers. - * @param user The user sending the message - * @param dest The target of the message (Channel* or User*) - * @param target_type The type of target (TYPE_USER or TYPE_CHANNEL) - * @param text Changeable text being sent by the user - * @param status The status being used, e.g. PRIVMSG @#chan has status== '@', 0 to send to everyone. - * @param exempt_list A list of users not to send to. For channel notices, this will usually contain just the sender. - * It will be ignored for private notices. - * @return 1 to deny the NOTICE, 0 to allow it - */ - virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list); + virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text,char status, CUList &exempt_list, MessageType msgtype); /** Called when sending a message to all "neighbors" of a given user - * that is, all users that share a common channel. This is used in @@ -702,25 +682,14 @@ class CoreExport Module : public classbase, public usecountbase * @param text the text being sent by the user * @param status The status being used, e.g. PRIVMSG @#chan has status== '@', 0 to send to everyone. * @param exempt_list A list of users to not send to. + * @param msgtype The message type, MSG_PRIVMSG for PRIVMSGs, MSG_NOTICE for NOTICEs */ - virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list); - - /** Called after any NOTICE sent from a user. - * The dest variable contains a User* if target_type is TYPE_USER and a Channel* - * if target_type is TYPE_CHANNEL. - * @param user The user sending the message - * @param dest The target of the message - * @param target_type The type of target (TYPE_USER or TYPE_CHANNEL) - * @param text the text being sent by the user - * @param status The status being used, e.g. NOTICE @#chan has status== '@', 0 to send to everyone. - * @param exempt_list A list of users to not send to. - */ - virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list); + virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list, MessageType msgtype); /** Called immediately before any NOTICE or PRIVMSG sent from a user, local or remote. * The dest variable contains a User* if target_type is TYPE_USER and a Channel* * if target_type is TYPE_CHANNEL. - * The difference between this event and OnUserPreNotice/OnUserPreMessage is that delivery is gauranteed, + * The difference between this event and OnUserPreMessage is that delivery is gauranteed, * the message has already been vetted. In the case of the other two methods, a later module may stop your * message. This also differs from OnUserMessage which occurs AFTER the message has been sent. * @param user The user sending the message diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index d0845a051..ec60127b7 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -70,7 +70,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use ModResult MOD_RESULT; std::string temp = parameters[1]; - FIRST_MOD_RESULT(OnUserPreNotice, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list)); + FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list, MSG_NOTICE)); if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; const char* text = temp.c_str(); @@ -81,7 +81,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use { user->SendAll("NOTICE", "%s", text); } - FOREACH_MOD(I_OnUserNotice,OnUserNotice(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, exempt_list)); + FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, exempt_list, MSG_NOTICE)); return CMD_SUCCESS; } char status = 0; @@ -125,7 +125,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use ModResult MOD_RESULT; std::string temp = parameters[1]; - FIRST_MOD_RESULT(OnUserPreNotice, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status, exempt_list)); + FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status, exempt_list, MSG_NOTICE)); if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; @@ -155,7 +155,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %s :%s", chan->name.c_str(), text); } - FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,text,status,exempt_list)); + FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,text,status,exempt_list,MSG_NOTICE)); } else { @@ -201,7 +201,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use ModResult MOD_RESULT; std::string temp = parameters[1]; - FIRST_MOD_RESULT(OnUserPreNotice, MOD_RESULT, (user,dest,TYPE_USER,temp,0,exempt_list)); + FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, dest, TYPE_USER, temp, 0, exempt_list, MSG_NOTICE)); if (MOD_RESULT == MOD_RES_DENY) { return CMD_FAILURE; } @@ -215,7 +215,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use user->WriteTo(dest, "NOTICE %s :%s", dest->nick.c_str(), text); } - FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,text,0,exempt_list)); + FOREACH_MOD(I_OnUserMessage, OnUserMessage(user, dest, TYPE_USER, text, 0, exempt_list, MSG_NOTICE)); } else { diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 49845162c..b04e63d00 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -70,7 +70,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us ModResult MOD_RESULT; std::string temp = parameters[1]; - FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, except_list)); + FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, except_list, MSG_PRIVMSG)); if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; @@ -82,7 +82,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us { user->SendAll("PRIVMSG", "%s", text); } - FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list)); + FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list, MSG_PRIVMSG)); return CMD_SUCCESS; } char status = 0; @@ -127,7 +127,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us ModResult MOD_RESULT; std::string temp = parameters[1]; - FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status,except_list)); + FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, chan, TYPE_CHANNEL, temp, status, except_list, MSG_PRIVMSG)); if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; @@ -158,7 +158,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %s :%s", chan->name.c_str(), text); } - FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,text,status,except_list)); + FOREACH_MOD(I_OnUserMessage, OnUserMessage(user,chan, TYPE_CHANNEL, text, status, except_list, MSG_PRIVMSG)); } else { @@ -211,7 +211,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us ModResult MOD_RESULT; std::string temp = parameters[1]; - FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, dest, TYPE_USER, temp, 0, except_list)); + FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, dest, TYPE_USER, temp, 0, except_list, MSG_PRIVMSG)); if (MOD_RESULT == MOD_RES_DENY) return CMD_FAILURE; @@ -225,7 +225,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us user->WriteTo(dest, "PRIVMSG %s :%s", dest->nick.c_str(), text); } - FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, dest, TYPE_USER, text, 0, except_list)); + FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, dest, TYPE_USER, text, 0, except_list, MSG_PRIVMSG)); } else { diff --git a/src/modules.cpp b/src/modules.cpp index 63e1118d9..9a7d8a6a7 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -103,8 +103,7 @@ void Module::OnPostOper(User*, const std::string&, const std::string &) { } void Module::OnInfo(User*) { } void Module::OnWhois(User*, User*) { } ModResult Module::OnUserPreInvite(User*, User*, Channel*, time_t) { return MOD_RES_PASSTHRU; } -ModResult Module::OnUserPreMessage(User*, void*, int, std::string&, char, CUList&) { return MOD_RES_PASSTHRU; } -ModResult Module::OnUserPreNotice(User*, void*, int, std::string&, char, CUList&) { return MOD_RES_PASSTHRU; } +ModResult Module::OnUserPreMessage(User*, void*, int, std::string&, char, CUList&, MessageType) { return MOD_RES_PASSTHRU; } ModResult Module::OnUserPreNick(User*, const std::string&) { return MOD_RES_PASSTHRU; } void Module::OnUserPostNick(User*, const std::string&) { } ModResult Module::OnPreMode(User*, User*, Channel*, const std::vector<std::string>&) { return MOD_RES_PASSTHRU; } @@ -141,8 +140,7 @@ int Module::OnStreamSocketWrite(StreamSocket*, std::string&) { return -1; } void Module::OnStreamSocketClose(StreamSocket*) { } void Module::OnStreamSocketConnect(StreamSocket*) { } int Module::OnStreamSocketRead(StreamSocket*, std::string&) { return -1; } -void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&) { } -void Module::OnUserNotice(User*, void*, int, const std::string&, char, const CUList&) { } +void Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { } void Module::OnRemoteKill(User*, User*, const std::string&, const std::string&) { } void Module::OnUserInvite(User*, User*, Channel*, time_t) { } void Module::OnPostTopicChange(User*, Channel*, const std::string&) { } diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index b08f72011..c9fa9bd0a 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -175,9 +175,9 @@ class ModuleAlias : public Module return MOD_RES_PASSTHRU; } - void OnUserMessage(User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list) CXX11_OVERRIDE + void OnUserMessage(User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list, MessageType msgtype) CXX11_OVERRIDE { - if (target_type != TYPE_CHANNEL) + if ((target_type != TYPE_CHANNEL) || (msgtype != MSG_PRIVMSG)) { return; } diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index c9c14f01b..e67c0db80 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -49,7 +49,7 @@ public: { OnRehash(NULL); ServerInstance->Modules->AddService(bc); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreMessage, I_OnRehash, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -63,7 +63,7 @@ public: ReadConf(); } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_CHANNEL) { @@ -105,11 +105,6 @@ public: return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - void ReadConf() { ConfigTag* tag = ServerInstance->Config->ConfValue("blockcaps"); diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index a0a178877..2c7207698 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -45,7 +45,7 @@ class ModuleBlockColor : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(bc); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -54,7 +54,7 @@ class ModuleBlockColor : public Module tokens["EXTBAN"].push_back('c'); } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { @@ -86,11 +86,6 @@ class ModuleBlockColor : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Provides channel mode +c to block color",VF_VENDOR); diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 1743be1dc..9cc9aaf5e 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -352,7 +352,7 @@ public: ServerInstance->Modules->AddService(cmd); ServerInstance->Modules->AddService(cmd.extInfo); - Implementation eventlist[] = { I_OnRehash, I_OnUserPostNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage }; + Implementation eventlist[] = { I_OnRehash, I_OnUserPostNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreMessage }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -394,15 +394,7 @@ public: return MOD_RES_PASSTHRU; } - ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - if (IS_LOCAL(user) && target_type == TYPE_USER) - return PreText(user, (User*)dest, text); - - return MOD_RES_PASSTHRU; - } - - ModResult OnUserPreNotice(User* user, void* dest, int target_type, std::string& text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (IS_LOCAL(user) && target_type == TYPE_USER) return PreText(user, (User*)dest, text); diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index fa573a699..03b99c77c 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -62,12 +62,12 @@ class ModuleCensor : public Module OnRehash(NULL); ServerInstance->Modules->AddService(cu); ServerInstance->Modules->AddService(cc); - Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice }; + Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } // format of a config entry is <badword text="shit" replace="poo"> - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (!IS_LOCAL(user)) return MOD_RES_PASSTHRU; @@ -107,11 +107,6 @@ class ModuleCensor : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - void OnRehash(User* user) CXX11_OVERRIDE { /* diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 7784d7396..8e0bbd538 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -82,7 +82,7 @@ class ModuleChanFilter : public Module ServerInstance->Modules->AddService(cf); cf.DoImplements(this); - Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnUserPreNotice, I_OnSyncChannel }; + Implementation eventlist[] = { I_OnRehash, I_OnUserPreMessage, I_OnSyncChannel }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); OnRehash(NULL); @@ -121,7 +121,7 @@ class ModuleChanFilter : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_CHANNEL) { @@ -130,11 +130,6 @@ class ModuleChanFilter : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - void OnSyncChannel(Channel* chan, Module* proto, void* opaque) CXX11_OVERRIDE { cf.DoSyncChannel(chan, proto, opaque); diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index e814e0206..c114891bb 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -133,9 +133,9 @@ class ModuleChanHistory : public Module sendnotice = tag->getBool("notice", true); } - void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList&) CXX11_OVERRIDE + void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList&, MessageType msgtype) CXX11_OVERRIDE { - if (target_type == TYPE_CHANNEL && status == 0) + if ((target_type == TYPE_CHANNEL) && (status == 0) && (msgtype == MSG_PRIVMSG)) { Channel* c = (Channel*)dest; HistoryList* list = m.ext.get(c); diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp index f4a9d8b64..d9ab03053 100644 --- a/src/modules/m_commonchans.cpp +++ b/src/modules/m_commonchans.cpp @@ -40,8 +40,7 @@ class ModulePrivacyMode : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(pm); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + ServerInstance->Modules->Attach(I_OnUserPreMessage, this); } Version GetVersion() CXX11_OVERRIDE @@ -49,7 +48,7 @@ class ModulePrivacyMode : public Module return Version("Adds user mode +c, which if set, users must be on a common channel with you to private message you", VF_VENDOR); } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_USER) { @@ -62,11 +61,6 @@ class ModulePrivacyMode : public Module } return MOD_RES_PASSTHRU; } - - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user, dest, target_type, text, status, exempt_list); - } }; MODULE_INIT(ModulePrivacyMode) diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index ac1cb1484..5061cf250 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -261,7 +261,7 @@ class ModuleDCCAllow : public Module ServerInstance->Modules->AddService(*ext); ServerInstance->Modules->AddService(cmd); ReadFileConf(); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPostNick, I_OnRehash }; + Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserQuit, I_OnUserPostNick, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -292,12 +292,7 @@ class ModuleDCCAllow : public Module RemoveNick(user); } - ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user, dest, target_type, text, status, exempt_list); - } - - ModResult OnUserPreNotice(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (!IS_LOCAL(user)) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index 31d0e6039..65591f070 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -70,7 +70,7 @@ class ModuleDeaf : public Module ServerInstance->Modules->AddService(m1); OnRehash(NULL); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash }; + Implementation eventlist[] = { I_OnUserPreMessage, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -81,25 +81,13 @@ class ModuleDeaf : public Module deaf_bypasschars_uline = tag->getString("bypasscharsuline"); } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_CHANNEL) { Channel* chan = (Channel*)dest; if (chan) - this->BuildDeafList(MSG_NOTICE, chan, user, status, text, exempt_list); - } - - return MOD_RES_PASSTHRU; - } - - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - if (target_type == TYPE_CHANNEL) - { - Channel* chan = (Channel*)dest; - if (chan) - this->BuildDeafList(MSG_PRIVMSG, chan, user, status, text, exempt_list); + this->BuildDeafList(msgtype, chan, user, status, text, exempt_list); } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index 752112a56..8391dc45e 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -56,7 +56,7 @@ class ModuleDelayMsg : public Module } Version GetVersion() CXX11_OVERRIDE; void OnUserJoin(Membership* memb, bool sync, bool created, CUList&) CXX11_OVERRIDE; - ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE; + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; }; ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) @@ -104,13 +104,13 @@ void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CULis } } -ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list) +ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) { /* Server origin */ if ((!user) || (!IS_LOCAL(user))) return MOD_RES_PASSTHRU; - if (target_type != TYPE_CHANNEL) + if ((target_type != TYPE_CHANNEL) || (msgtype != MSG_PRIVMSG)) return MOD_RES_PASSTHRU; Channel* channel = (Channel*) dest; diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 949d0e6e6..f161a16e8 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -181,11 +181,10 @@ class ModuleFilter : public Module ModuleFilter(); void init() CXX11_OVERRIDE; CullResult cull(); - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE; + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; FilterResult* FilterMatch(User* user, const std::string &text, int flags); bool DeleteFilter(const std::string &freeform); std::pair<bool, std::string> AddFilter(const std::string &freeform, FilterAction type, const std::string &reason, long duration, const std::string &flags); - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE; void OnRehash(User* user) CXX11_OVERRIDE; Version GetVersion() CXX11_OVERRIDE; std::string EncodeFilter(FilterResult* filter); @@ -304,7 +303,7 @@ ModuleFilter::ModuleFilter() void ModuleFilter::init() { ServerInstance->Modules->AddService(filtcommand); - Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncNetwork, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash, I_OnUnloadModule }; + Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncNetwork, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnRehash, I_OnUnloadModule }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); OnRehash(NULL); } @@ -323,23 +322,13 @@ void ModuleFilter::FreeFilters() filters.clear(); } -ModResult ModuleFilter::OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) -{ - if (!IS_LOCAL(user)) - return MOD_RES_PASSTHRU; - - flags = FLAG_PRIVMSG; - return OnUserPreNotice(user,dest,target_type,text,status,exempt_list); -} - -ModResult ModuleFilter::OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) +ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) { /* Leave ulines alone */ if ((ServerInstance->ULine(user->server)) || (!IS_LOCAL(user))) return MOD_RES_PASSTHRU; - if (!flags) - flags = FLAG_NOTICE; + flags = (msgtype == MSG_PRIVMSG) ? FLAG_PRIVMSG : FLAG_NOTICE; FilterResult* f = this->FilterMatch(user, text, flags); if (f) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 90010dc33..970087bef 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -132,8 +132,7 @@ class ModuleMsgFlood : public Module { ServerInstance->Modules->AddService(mf); ServerInstance->Modules->AddService(mf.ext); - Implementation eventlist[] = { I_OnUserPreNotice, I_OnUserPreMessage }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + ServerInstance->Modules->Attach(I_OnUserPreMessage, this); } ModResult ProcessMessages(User* user,Channel* dest, const std::string &text) @@ -172,15 +171,7 @@ class ModuleMsgFlood : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - if (target_type == TYPE_CHANNEL) - return ProcessMessages(user,(Channel*)dest,text); - - return MOD_RES_PASSTHRU; - } - - ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_CHANNEL) return ProcessMessages(user,(Channel*)dest,text); @@ -192,7 +183,6 @@ class ModuleMsgFlood : public Module { // we want to be after all modules that might deny the message (e.g. m_muteban, m_noctcp, m_blockcolor, etc.) ServerInstance->Modules->SetPriority(this, I_OnUserPreMessage, PRIORITY_LAST); - ServerInstance->Modules->SetPriority(this, I_OnUserPreNotice, PRIORITY_LAST); } Version GetVersion() CXX11_OVERRIDE diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp index 6c0c60fde..1b6cdff93 100644 --- a/src/modules/m_muteban.cpp +++ b/src/modules/m_muteban.cpp @@ -27,7 +27,7 @@ class ModuleQuietBan : public Module public: void init() CXX11_OVERRIDE { - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -36,7 +36,7 @@ class ModuleQuietBan : public Module return Version("Implements extban +b m: - mute bans",VF_OPTCOMMON|VF_VENDOR); } - ModResult OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL) return MOD_RES_PASSTHRU; @@ -51,11 +51,6 @@ class ModuleQuietBan : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user, dest, target_type, text, status, exempt_list); - } - void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE { tokens["EXTBAN"].push_back('m'); diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 4949a2777..29b548e1c 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -42,7 +42,7 @@ class ModuleNoCTCP : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(nc); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -51,12 +51,7 @@ class ModuleNoCTCP : public Module return Version("Provides channel mode +C to block CTCPs", VF_VENDOR); } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreNotice(user,dest,target_type,text,status,exempt_list); - } - - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index 2fbecc812..206362845 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -42,7 +42,7 @@ class ModuleNoNotice : public Module void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(nt); - Implementation eventlist[] = { I_OnUserPreNotice, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -51,10 +51,10 @@ class ModuleNoNotice : public Module tokens["EXTBAN"].push_back('T'); } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { ModResult res; - if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) + if ((msgtype == MSG_NOTICE) && (target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { Channel* c = (Channel*)dest; if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet('T'))) diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp index 2bde9886f..e4dbb1d43 100644 --- a/src/modules/m_restrictmsg.cpp +++ b/src/modules/m_restrictmsg.cpp @@ -23,20 +23,15 @@ /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */ - class ModuleRestrictMsg : public Module { - public: - void init() CXX11_OVERRIDE { - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + ServerInstance->Modules->Attach(I_OnUserPreMessage, this); } - - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if ((target_type == TYPE_USER) && (IS_LOCAL(user))) { @@ -58,11 +53,6 @@ class ModuleRestrictMsg : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return this->OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Forbids users from messaging each other. Users may still message opers and opers may message other opers.",VF_VENDOR); diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index bb4dc5ecc..e42c02ff2 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -122,7 +122,7 @@ class ModuleServicesAccount : public Module { ServiceProvider* providerlist[] = { &m1, &m2, &m3, &m4, &m5, &accountname }; ServerInstance->Modules->AddServices(providerlist, sizeof(providerlist)/sizeof(ServiceProvider*)); - Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin, I_OnCheckBan, + Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreJoin, I_OnCheckBan, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick, I_OnSetConnectClass }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); @@ -163,7 +163,7 @@ class ModuleServicesAccount : public Module } } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (!IS_LOCAL(user)) return MOD_RES_PASSTHRU; @@ -234,11 +234,6 @@ class ModuleServicesAccount : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user, dest, target_type, text, status, exempt_list); - } - ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE { std::string *account = accountname.get(user); diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 2a11a7b8b..0e9a45720 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -309,7 +309,7 @@ class ModuleSilence : public Module ServerInstance->Modules->AddService(cmdsvssilence); ServerInstance->Modules->AddService(cmdsilence.ext); - Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage, I_OnUserPreInvite }; + Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreMessage, I_OnUserPreInvite }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -343,33 +343,23 @@ class ModuleSilence : public Module } } - ModResult PreText(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list, int silence_type) + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (target_type == TYPE_USER && IS_LOCAL(((User*)dest))) { - return MatchPattern((User*)dest, user, silence_type); + return MatchPattern((User*)dest, user, ((msgtype == MSG_PRIVMSG) ? SILENCE_PRIVATE : SILENCE_NOTICE)); } else if (target_type == TYPE_CHANNEL) { Channel* chan = (Channel*)dest; if (chan) { - this->OnBuildExemptList((silence_type == SILENCE_PRIVATE ? MSG_PRIVMSG : MSG_NOTICE), chan, user, status, exempt_list, ""); + this->OnBuildExemptList(msgtype, chan, user, status, exempt_list, ""); } } return MOD_RES_PASSTHRU; } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return PreText(user, dest, target_type, text, status, exempt_list, SILENCE_PRIVATE); - } - - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return PreText(user, dest, target_type, text, status, exempt_list, SILENCE_NOTICE); - } - ModResult OnUserPreInvite(User* source,User* dest,Channel* channel, time_t timeout) CXX11_OVERRIDE { return MatchPattern(dest, source, SILENCE_INVITE); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 244180b2f..4934c3d61 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -73,7 +73,7 @@ void ModuleSpanningTree::init() Implementation eventlist[] = { I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostTopicChange, - I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin, + I_OnWallops, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin, I_OnChangeHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule, I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash, I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, @@ -495,14 +495,9 @@ void ModuleSpanningTree::LocalMessage(User* user, void* dest, int target_type, c } } -void ModuleSpanningTree::OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) +void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) { - LocalMessage(user, dest, target_type, text, status, exempt_list, "NOTICE"); -} - -void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) -{ - LocalMessage(user, dest, target_type, text, status, exempt_list, "PRIVMSG"); + LocalMessage(user, dest, target_type, text, status, exempt_list, (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE")); } void ModuleSpanningTree::OnBackgroundTimer(time_t curtime) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 9ea48aaea..947eddd37 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -148,8 +148,7 @@ class ModuleSpanningTree : public Module void OnUserInvite(User* source,User* dest,Channel* channel, time_t) CXX11_OVERRIDE; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE; void OnWallops(User* user, const std::string &text) CXX11_OVERRIDE; - void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) CXX11_OVERRIDE; - void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list) CXX11_OVERRIDE; + void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE; void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE; void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE; diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 71561a7a0..b7e26afd5 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -54,7 +54,7 @@ class ModuleStripColor : public Module { ServerInstance->Modules->AddService(usc); ServerInstance->Modules->AddService(csc); - Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric }; + Implementation eventlist[] = { I_OnUserPreMessage, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -63,7 +63,7 @@ class ModuleStripColor : public Module tokens["EXTBAN"].push_back('S'); } - ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE { if (!IS_LOCAL(user)) return MOD_RES_PASSTHRU; @@ -93,11 +93,6 @@ class ModuleStripColor : public Module return MOD_RES_PASSTHRU; } - ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE - { - return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); - } - Version GetVersion() CXX11_OVERRIDE { return Version("Provides channel +S mode (strip ansi color)", VF_VENDOR); diff --git a/src/modules/m_testnet.cpp b/src/modules/m_testnet.cpp index a18e7dede..0aeeebb88 100644 --- a/src/modules/m_testnet.cpp +++ b/src/modules/m_testnet.cpp @@ -112,10 +112,8 @@ static void checkall(Module* noimpl) CHK(OnUserPreInvite); CHK(OnUserInvite); CHK(OnUserPreMessage); - CHK(OnUserPreNotice); CHK(OnUserPreNick); CHK(OnUserMessage); - CHK(OnUserNotice); CHK(OnMode); CHK(OnGetServerDescription); CHK(OnSyncUser); |