summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-01-08 12:52:07 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-01-08 12:52:07 +0100
commit833ae95adc3d8e0b7ba0e82af4cbd173bb98431e (patch)
tree572ed0df4e949a343ad51731eba42936151544bb /src/modules
parentd379dcab405bd4b0542e3c645a2de3c1a27832b8 (diff)
Remove PreText()-like functions
Do processing in OnUserPreMessage()
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_callerid.cpp14
-rw-r--r--src/modules/m_chanfilter.cpp15
-rw-r--r--src/modules/m_deaf.cpp18
-rw-r--r--src/modules/m_messageflood.cpp14
4 files changed, 21 insertions, 40 deletions
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 1a2fd3a84..3dc932958 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -383,8 +383,12 @@ public:
tokens["CALLERID"] = "g";
}
- ModResult PreText(User* user, User* dest, std::string& text)
+ ModResult OnUserPreMessage(User* user, void* voiddest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
{
+ if (!IS_LOCAL(user) || target_type != TYPE_USER)
+ return MOD_RES_PASSTHRU;
+
+ User* dest = static_cast<User*>(voiddest);
if (!dest->IsModeSet(myumode) || (user == dest))
return MOD_RES_PASSTHRU;
@@ -411,14 +415,6 @@ public:
return MOD_RES_PASSTHRU;
}
- 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);
-
- return MOD_RES_PASSTHRU;
- }
-
void OnUserPostNick(User* user, const std::string& oldnick) CXX11_OVERRIDE
{
if (!tracknick)
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 2828dca30..57b58df19 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -81,8 +81,12 @@ class ModuleChanFilter : public Module
cf.DoRehash();
}
- ModResult ProcessMessages(User* user,Channel* chan,std::string &text)
+ 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 MOD_RES_PASSTHRU;
+
+ Channel* chan = static_cast<Channel*>(dest);
ModResult res = ServerInstance->OnCheckExemption(user,chan,"filter");
if (!IS_LOCAL(user) || res == MOD_RES_ALLOW)
@@ -108,15 +112,6 @@ 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, MessageType msgtype) CXX11_OVERRIDE
- {
- if (target_type == TYPE_CHANNEL)
- {
- return ProcessMessages(user,(Channel*)dest,text);
- }
- return MOD_RES_PASSTHRU;
- }
-
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides channel-specific censor lists (like mode +G but varies from channel to channel)", VF_VENDOR);
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 7d716de7e..ce6571b8c 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -62,18 +62,10 @@ class ModuleDeaf : public Module
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(msgtype, chan, user, status, text, exempt_list);
- }
-
- return MOD_RES_PASSTHRU;
- }
+ if (target_type != TYPE_CHANNEL)
+ return MOD_RES_PASSTHRU;
- void BuildDeafList(MessageType message_type, Channel* chan, User* sender, char status, const std::string &text, CUList &exempt_list)
- {
+ Channel* chan = static_cast<Channel*>(dest);
const UserMembList *ulist = chan->GetUsers();
bool is_bypasschar = (deaf_bypasschars.find(text[0]) != std::string::npos);
bool is_bypasschar_uline = (deaf_bypasschars_uline.find(text[0]) != std::string::npos);
@@ -83,7 +75,7 @@ class ModuleDeaf : public Module
* Than it is obviously going to get through +d, no build required
*/
if (!deaf_bypasschars_uline.empty() && is_bypasschar)
- return;
+ return MOD_RES_PASSTHRU;
for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++)
{
@@ -108,6 +100,8 @@ class ModuleDeaf : public Module
/* don't deliver message! */
exempt_list.insert(i->first);
}
+
+ return MOD_RES_PASSTHRU;
}
Version GetVersion() CXX11_OVERRIDE
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 70ba8bd78..e2d752d18 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -124,8 +124,12 @@ class ModuleMsgFlood : public Module
{
}
- ModResult ProcessMessages(User* user,Channel* dest, const std::string &text)
+ ModResult OnUserPreMessage(User* user, void* voiddest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
{
+ if (target_type != TYPE_CHANNEL)
+ return MOD_RES_PASSTHRU;
+
+ Channel* dest = static_cast<Channel*>(voiddest);
if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf))
return MOD_RES_PASSTHRU;
@@ -160,14 +164,6 @@ 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, MessageType msgtype) CXX11_OVERRIDE
- {
- if (target_type == TYPE_CHANNEL)
- return ProcessMessages(user,(Channel*)dest,text);
-
- return MOD_RES_PASSTHRU;
- }
-
void Prioritize()
{
// we want to be after all modules that might deny the message (e.g. m_muteban, m_noctcp, m_blockcolor, etc.)