diff options
Diffstat (limited to 'src/modules')
29 files changed, 78 insertions, 195 deletions
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 1886b39bd..0e1fa945f 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_cban.cpp b/src/modules/m_cban.cpp index 044aa45a5..5e629ed42 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -29,12 +29,15 @@ */ class CBan : public XLine { -public: +private: + std::string displaytext; irc::string matchtext; +public: CBan(time_t s_time, long d, std::string src, std::string re, std::string ch) : XLine(s_time, d, src, re, "CBAN") { + this->displaytext = ch; this->matchtext = ch.c_str(); } @@ -51,9 +54,9 @@ public: return false; } - const char* Displayable() + const std::string& Displayable() { - return matchtext.c_str(); + return displaytext; } }; 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 4d4e2eb51..d138c44cd 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_rline.cpp b/src/modules/m_rline.cpp index 161cd4d0f..aa96d4951 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -92,9 +92,9 @@ class RLine : public XLine DefaultApply(u, "R", false); } - const char* Displayable() + const std::string& Displayable() { - return matchtext.c_str(); + return matchtext; } std::string matchtext; 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_shun.cpp b/src/modules/m_shun.cpp index e7dc3086d..6da24208a 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -56,9 +56,9 @@ public: return false; } - const char* Displayable() + const std::string& Displayable() { - return matchtext.c_str(); + return matchtext; } }; 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 92d274679..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, @@ -380,12 +380,8 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para */ void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...) { - char text[MAXBUF]; - va_list argsPtr; - - va_start(argsPtr, format); - vsnprintf(text, MAXBUF, format, argsPtr); - va_end(argsPtr); + std::string text; + VAFORMAT(text, format, format); if (IS_LOCAL(user)) user->WriteNotice(text); @@ -499,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) -{ - 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) +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, "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_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index c22ad3acb..639a397c6 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -120,7 +120,6 @@ void TreeSocket::SendFJoins(Channel* c) void TreeSocket::SendXLines() { char data[MAXBUF]; - const char* sn = ServerInstance->Config->GetSID().c_str(); std::vector<std::string> types = ServerInstance->XLines->GetAllTypes(); @@ -140,7 +139,10 @@ void TreeSocket::SendXLines() if (!i->second->IsBurstable()) break; - snprintf(data,MAXBUF,":%s ADDLINE %s %s %s %lu %lu :%s",sn, it->c_str(), i->second->Displayable(), + snprintf(data, MAXBUF, ":%s ADDLINE %s %s %s %lu %lu :%s", + ServerInstance->Config->GetSID().c_str(), + it->c_str(), + i->second->Displayable().c_str(), i->second->source.c_str(), (unsigned long)i->second->set_time, (unsigned long)i->second->duration, 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_svshold.cpp b/src/modules/m_svshold.cpp index bd80bb048..d35d5f3ba 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -30,12 +30,12 @@ class SVSHold : public XLine { public: - irc::string nickname; + std::string nickname; SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick) : XLine(s_time, d, src, re, "SVSHOLD") { - this->nickname = nick.c_str(); + this->nickname = nick; } bool Matches(User *u) @@ -47,14 +47,12 @@ public: bool Matches(const std::string &s) { - if (nickname == s) - return true; - return false; + return InspIRCd::Match(s, nickname); } - const char* Displayable() + const std::string& Displayable() { - return nickname.c_str(); + return nickname; } }; 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); diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index f73262f5a..e325fc088 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -125,8 +125,12 @@ class ModuleXLineDB : public Module for (LookupIter i = lookup->begin(); i != lookup->end(); ++i) { XLine* line = i->second; - fprintf(f, "LINE %s %s %s %lu %lu :%s\n", line->type.c_str(), line->Displayable(), - ServerInstance->Config->ServerName.c_str(), (unsigned long)line->set_time, (unsigned long)line->duration, line->reason.c_str()); + fprintf(f, "LINE %s %s %s %lu %lu :%s\n", + line->type.c_str(), + line->Displayable().c_str(), + ServerInstance->Config->ServerName.c_str(), + (unsigned long)line->set_time, + (unsigned long)line->duration, line->reason.c_str()); } } |