summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_alias.cpp14
-rw-r--r--src/modules/m_blockcaps.cpp16
-rw-r--r--src/modules/m_blockcolor.cpp8
-rw-r--r--src/modules/m_callerid.cpp6
-rw-r--r--src/modules/m_censor.cpp17
-rw-r--r--src/modules/m_chanfilter.cpp8
-rw-r--r--src/modules/m_chanhistory.cpp8
-rw-r--r--src/modules/m_commonchans.cpp6
-rw-r--r--src/modules/m_dccallow.cpp12
-rw-r--r--src/modules/m_deaf.cpp12
-rw-r--r--src/modules/m_delayjoin.cpp15
-rw-r--r--src/modules/m_delaymsg.cpp8
-rw-r--r--src/modules/m_filter.cpp20
-rw-r--r--src/modules/m_ircv3_echomessage.cpp22
-rw-r--r--src/modules/m_messageflood.cpp6
-rw-r--r--src/modules/m_muteban.cpp6
-rw-r--r--src/modules/m_noctcp.cpp8
-rw-r--r--src/modules/m_nonotice.cpp6
-rw-r--r--src/modules/m_repeat.cpp8
-rw-r--r--src/modules/m_restrictmsg.cpp6
-rw-r--r--src/modules/m_services_account.cpp10
-rw-r--r--src/modules/m_silence.cpp12
-rw-r--r--src/modules/m_spanningtree/main.cpp22
-rw-r--r--src/modules/m_spanningtree/main.h2
-rw-r--r--src/modules/m_stripcolor.cpp12
25 files changed, 137 insertions, 133 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 791186414..01338e8b4 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -162,9 +162,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, MessageType msgtype) CXX11_OVERRIDE
+ void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE
{
- if ((target_type != TYPE_CHANNEL) || (msgtype != MSG_PRIVMSG))
+ if ((target.type != MessageTarget::TYPE_CHANNEL) || (details.type != MSG_PRIVMSG))
{
return;
}
@@ -181,11 +181,11 @@ class ModuleAlias : public Module
return;
}
- Channel *c = (Channel *)dest;
+ Channel *c = target.Get<Channel>();
std::string scommand;
// text is like "!moo cows bite me", we want "!moo" first
- irc::spacesepstream ss(text);
+ irc::spacesepstream ss(details.text);
ss.GetToken(scommand);
if (scommand.size() <= fprefix.size())
@@ -207,7 +207,7 @@ class ModuleAlias : public Module
return;
/* The parameters for the command in their original form, with the command stripped off */
- std::string compare(text, scommand.length() + fprefix.size());
+ std::string compare(details.text, scommand.length() + fprefix.size());
while (*(compare.c_str()) == ' ')
compare.erase(compare.begin());
@@ -216,7 +216,7 @@ class ModuleAlias : public Module
if (i->second.ChannelCommand)
{
// We use substr here to remove the fantasy prefix
- if (DoAlias(user, c, &(i->second), compare, text.substr(fprefix.size())))
+ if (DoAlias(user, c, &(i->second), compare, details.text.substr(fprefix.size())))
return;
}
}
@@ -343,7 +343,7 @@ class ModuleAlias : public Module
{
// Prioritise after spanningtree so that channel aliases show the alias before the effects.
Module* linkmod = ServerInstance->Modules->Find("m_spanningtree.so");
- ServerInstance->Modules->SetPriority(this, I_OnUserMessage, PRIORITY_AFTER, linkmod);
+ ServerInstance->Modules->SetPriority(this, I_OnUserPostMessage, PRIORITY_AFTER, linkmod);
}
};
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index c36eeabff..eba86f94b 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -44,14 +44,14 @@ public:
tokens["EXTBAN"].push_back('B');
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type == TYPE_CHANNEL)
+ if (target.type == MessageTarget::TYPE_CHANNEL)
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
- Channel* c = (Channel*)dest;
+ Channel* c = target.Get<Channel>();
ModResult res = CheckExemption::Call(exemptionprov, user, c, "blockcaps");
if (res == MOD_RES_ALLOW)
@@ -61,17 +61,17 @@ public:
{
// If the message is a CTCP then we skip it unless it is
// an ACTION in which case we strip the prefix and suffix.
- std::string::const_iterator text_begin = text.begin();
- std::string::const_iterator text_end = text.end();
- if (text[0] == '\1')
+ std::string::const_iterator text_begin = details.text.begin();
+ std::string::const_iterator text_end = details.text.end();
+ if (details.text[0] == '\1')
{
// If the CTCP is not an action then skip it.
- if (text.compare(0, 8, "\1ACTION ", 8))
+ if (details.text.compare(0, 8, "\1ACTION ", 8))
return MOD_RES_PASSTHRU;
// Skip the CTCP message characters.
text_begin += 8;
- if (*text.rbegin() == '\1')
+ if (*details.text.rbegin() == '\1')
text_end -= 1;
}
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index e3135185d..43d0826dd 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -41,11 +41,11 @@ 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, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
+ if ((target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user)))
{
- Channel* c = (Channel*)dest;
+ Channel* c = target.Get<Channel>();
ModResult res = CheckExemption::Call(exemptionprov, user, c, "blockcolor");
if (res == MOD_RES_ALLOW)
@@ -53,7 +53,7 @@ class ModuleBlockColor : public Module
if (!c->GetExtBanStatus(user, 'c').check(!c->IsModeSet(bc)))
{
- for (std::string::iterator i = text.begin(); i != text.end(); i++)
+ for (std::string::iterator i = details.text.begin(); i != details.text.end(); i++)
{
switch (*i)
{
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 2f6199382..349c48c29 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -374,12 +374,12 @@ public:
tokens["CALLERID"] = ConvToStr(myumode.GetModeChar());
}
- ModResult OnUserPreMessage(User* user, void* voiddest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (!IS_LOCAL(user) || target_type != TYPE_USER)
+ if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_USER)
return MOD_RES_PASSTHRU;
- User* dest = static_cast<User*>(voiddest);
+ User* dest = target.Get<User>();
if (!dest->IsModeSet(myumode) || (user == dest))
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 6394ba9d0..fce00dfc7 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -41,18 +41,18 @@ class ModuleCensor : public Module
}
// 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, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
bool active = false;
- if (target_type == TYPE_USER)
- active = ((User*)dest)->IsModeSet(cu);
- else if (target_type == TYPE_CHANNEL)
+ if (target.type == MessageTarget::TYPE_USER)
+ active = target.Get<User>()->IsModeSet(cu);
+ else if (target.type == MessageTarget::TYPE_CHANNEL)
{
- Channel* c = (Channel*)dest;
+ Channel* c = target.Get<Channel>();
active = c->IsModeSet(cc);
ModResult res = CheckExemption::Call(exemptionprov, user, c, "censor");
@@ -63,21 +63,22 @@ class ModuleCensor : public Module
if (!active)
return MOD_RES_PASSTHRU;
- irc::string text2 = text.c_str();
+ irc::string text2 = details.text.c_str();
for (censor_t::iterator index = censors.begin(); index != censors.end(); index++)
{
if (text2.find(index->first) != irc::string::npos)
{
if (index->second.empty())
{
- user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first.c_str(), "Your message contained a censored word, and was blocked");
+ const std::string targname = target.type == MessageTarget::TYPE_CHANNEL ? target.Get<Channel>()->name : target.Get<User>()->nick;
+ user->WriteNumeric(ERR_WORDFILTERED, targname, index->first.c_str(), "Your message contained a censored word, and was blocked");
return MOD_RES_DENY;
}
stdalgo::string::replace_all(text2, index->first, index->second);
}
}
- text = text2.c_str();
+ details.text = text2.c_str();
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 133c5180d..e7dc6372b 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -80,12 +80,12 @@ class ModuleChanFilter : public Module
cf.DoRehash();
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type != TYPE_CHANNEL)
+ if (target.type != MessageTarget::TYPE_CHANNEL)
return MOD_RES_PASSTHRU;
- Channel* chan = static_cast<Channel*>(dest);
+ Channel* chan = target.Get<Channel>();
ModResult res = CheckExemption::Call(exemptionprov, user, chan, "filter");
if (!IS_LOCAL(user) || res == MOD_RES_ALLOW)
@@ -97,7 +97,7 @@ class ModuleChanFilter : public Module
{
for (ListModeBase::ModeList::iterator i = list->begin(); i != list->end(); i++)
{
- if (InspIRCd::Match(text, i->mask))
+ if (InspIRCd::Match(details.text, i->mask))
{
if (hidemask)
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)");
diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp
index e8a516b94..4d74b65e0 100644
--- a/src/modules/m_chanhistory.cpp
+++ b/src/modules/m_chanhistory.cpp
@@ -121,15 +121,15 @@ class ModuleChanHistory : public Module
dobots = tag->getBool("bots", true);
}
- void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList&, MessageType msgtype) CXX11_OVERRIDE
+ void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE
{
- if ((target_type == TYPE_CHANNEL) && (status == 0) && (msgtype == MSG_PRIVMSG))
+ if ((target.type == MessageTarget::TYPE_CHANNEL) && (target.status == 0) && (details.type == MSG_PRIVMSG))
{
- Channel* c = (Channel*)dest;
+ Channel* c = target.Get<Channel>();
HistoryList* list = m.ext.get(c);
if (list)
{
- const std::string line = ":" + user->GetFullHost() + " PRIVMSG " + c->name + " :" + text;
+ const std::string line = ":" + user->GetFullHost() + " PRIVMSG " + c->name + " :" + details.text;
list->lines.push_back(HistoryItem(line));
if (list->lines.size() > list->maxlen)
list->lines.pop_front();
diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp
index 678be0c43..4cef93029 100644
--- a/src/modules/m_commonchans.cpp
+++ b/src/modules/m_commonchans.cpp
@@ -33,11 +33,11 @@ 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, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type == TYPE_USER)
+ if (target.type == MessageTarget::TYPE_USER)
{
- User* t = (User*)dest;
+ User* t = target.Get<User>();
if (!user->IsOper() && (t->IsModeSet(pm)) && (!user->server->IsULine()) && !user->SharesChannelWith(t))
{
user->WriteNumeric(ERR_CANTSENDTOUSER, t->nick, "You are not permitted to send private messages to this user (+c set)");
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 18ec87179..65eeeba11 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -299,27 +299,27 @@ class ModuleDCCAllow : public Module
RemoveNick(user);
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
- if (target_type == TYPE_USER)
+ if (target.type == MessageTarget::TYPE_USER)
{
- User* u = (User*)dest;
+ User* u = target.Get<User>();
/* Always allow a user to dcc themselves (although... why?) */
if (user == u)
return MOD_RES_PASSTHRU;
- if ((text.length()) && (text[0] == '\1'))
+ if ((details.text.length()) && (details.text[0] == '\1'))
{
Expire();
// :jamie!jamie@test-D4457903BA652E0F.silverdream.org PRIVMSG eimaj :DCC SEND m_dnsbl.cpp 3232235786 52650 9676
// :jamie!jamie@test-D4457903BA652E0F.silverdream.org PRIVMSG eimaj :VERSION
- if (strncmp(text.c_str(), "\1DCC ", 5) == 0)
+ if (strncmp(details.text.c_str(), "\1DCC ", 5) == 0)
{
dl = ext.get(u);
if (dl && dl->size())
@@ -329,7 +329,7 @@ class ModuleDCCAllow : public Module
return MOD_RES_PASSTHRU;
}
- std::string buf = text.substr(5);
+ std::string buf = details.text.substr(5);
size_t s = buf.find(' ');
if (s == std::string::npos)
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 7cad49d76..e58d130a5 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -60,14 +60,14 @@ class ModuleDeaf : public Module
deaf_bypasschars_uline = tag->getString("bypasscharsuline");
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type != TYPE_CHANNEL)
+ if (target.type != MessageTarget::TYPE_CHANNEL)
return MOD_RES_PASSTHRU;
- Channel* chan = static_cast<Channel*>(dest);
- bool is_bypasschar = (deaf_bypasschars.find(text[0]) != std::string::npos);
- bool is_bypasschar_uline = (deaf_bypasschars_uline.find(text[0]) != std::string::npos);
+ Channel* chan = target.Get<Channel>();
+ bool is_bypasschar = (deaf_bypasschars.find(details.text[0]) != std::string::npos);
+ bool is_bypasschar_uline = (deaf_bypasschars_uline.find(details.text[0]) != std::string::npos);
/*
* If we have no bypasschars_uline in config, and this is a bypasschar (regular)
@@ -95,7 +95,7 @@ class ModuleDeaf : public Module
continue; /* deliver message */
/* don't deliver message! */
- exempt_list.insert(i->first);
+ details.exemptions.insert(i->first);
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp
index d26a56568..f9cd837d7 100644
--- a/src/modules/m_delayjoin.cpp
+++ b/src/modules/m_delayjoin.cpp
@@ -24,7 +24,6 @@
class DelayJoinMode : public ModeHandler
{
- CUList empty;
public:
DelayJoinMode(Module* Parent) : ModeHandler(Parent, "delayjoin", 'D', PARAM_NONE, MODETYPE_CHANNEL)
{
@@ -52,7 +51,7 @@ class ModuleDelayJoin : public Module
void OnUserPart(Membership*, std::string &partmessage, CUList&) CXX11_OVERRIDE;
void OnUserKick(User* source, Membership*, const std::string &reason, CUList&) CXX11_OVERRIDE;
void OnBuildNeighborList(User* source, IncludeChanList& include, std::map<User*, bool>& exception) CXX11_OVERRIDE;
- void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list) CXX11_OVERRIDE;
+ void OnUserMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE;
ModResult OnRawMode(User* user, Channel* channel, ModeHandler* mh, const std::string& param, bool adding) CXX11_OVERRIDE;
};
@@ -68,9 +67,13 @@ ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channe
* Make all users visible, as +D is being removed. If we don't do this,
* they remain permanently invisible on this channel!
*/
+ MessageTarget msgtarget(channel, 0);
+ MessageDetails msgdetails(MSG_PRIVMSG, "");
const Channel::MemberMap& users = channel->GetUsers();
for (Channel::MemberMap::const_iterator n = users.begin(); n != users.end(); ++n)
- creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty);
+ {
+ creator->OnUserMessage(n->first, msgtarget, msgdetails);
+ }
}
channel->SetMode(this, adding);
return MODEACTION_ALLOW;
@@ -138,12 +141,12 @@ void ModuleDelayJoin::OnBuildNeighborList(User* source, IncludeChanList& include
}
}
-void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list)
+void ModuleDelayJoin::OnUserMessage(User* user, const MessageTarget& target, const MessageDetails& details)
{
- if (target_type != TYPE_CHANNEL)
+ if (target.type != MessageTarget::TYPE_CHANNEL)
return;
- Channel* channel = static_cast<Channel*>(dest);
+ Channel* channel = target.Get<Channel>();
Membership* memb = channel->GetUser(user);
if (!memb || !unjoined.set(memb, 0))
diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp
index 247630e65..b39fb1d0a 100644
--- a/src/modules/m_delaymsg.cpp
+++ b/src/modules/m_delaymsg.cpp
@@ -55,7 +55,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, MessageType msgtype) CXX11_OVERRIDE;
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE;
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE;
};
@@ -93,15 +93,15 @@ 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, MessageType msgtype)
+ModResult ModuleDelayMsg::OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details)
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
- if ((target_type != TYPE_CHANNEL) || ((!allownotice) && (msgtype == MSG_NOTICE)))
+ if ((target.type != MessageTarget::TYPE_CHANNEL) || ((!allownotice) && (details.type == MSG_NOTICE)))
return MOD_RES_PASSTHRU;
- Channel* channel = (Channel*) dest;
+ Channel* channel = target.Get<Channel>();
Membership* memb = channel->GetUser(user);
if (!memb)
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 7f5be3639..8ad692971 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -183,7 +183,7 @@ class ModuleFilter : public Module, public ServerEventListener
ModuleFilter();
CullResult cull() CXX11_OVERRIDE;
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE;
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) 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);
@@ -322,30 +322,30 @@ void ModuleFilter::FreeFilters()
filters.clear();
}
-ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype)
+ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtarget, MessageDetails& details)
{
// Leave remote users and servers alone
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
- flags = (msgtype == MSG_PRIVMSG) ? FLAG_PRIVMSG : FLAG_NOTICE;
+ flags = (details.type == MSG_PRIVMSG) ? FLAG_PRIVMSG : FLAG_NOTICE;
- FilterResult* f = this->FilterMatch(user, text, flags);
+ FilterResult* f = this->FilterMatch(user, details.text, flags);
if (f)
{
std::string target;
- if (target_type == TYPE_USER)
+ if (msgtarget.type == MessageTarget::TYPE_USER)
{
- User* t = (User*)dest;
+ User* t = msgtarget.Get<User>();
// Check if the target nick is exempted, if yes, ignore this message
if (exemptednicks.count(t->nick))
return MOD_RES_PASSTHRU;
target = t->nick;
}
- else if (target_type == TYPE_CHANNEL)
+ else if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
{
- Channel* t = (Channel*)dest;
+ Channel* t = msgtarget.Get<Channel>();
if (exemptedchans.count(t->name))
return MOD_RES_PASSTHRU;
@@ -354,14 +354,14 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type
if (f->action == FA_BLOCK)
{
ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason);
- if (target_type == TYPE_CHANNEL)
+ if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str()));
else
user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason);
}
else if (f->action == FA_SILENT)
{
- if (target_type == TYPE_CHANNEL)
+ if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str()));
else
user->WriteNotice("Your message to "+target+" was blocked: "+f->reason);
diff --git a/src/modules/m_ircv3_echomessage.cpp b/src/modules/m_ircv3_echomessage.cpp
index 8773d7187..c2818700f 100644
--- a/src/modules/m_ircv3_echomessage.cpp
+++ b/src/modules/m_ircv3_echomessage.cpp
@@ -33,31 +33,31 @@ class ModuleIRCv3EchoMessage : public Module
{
}
- void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE
{
if (!cap.get(user))
return;
- std::string msg = MessageTypeStringSp[msgtype];
- if (target_type == TYPE_USER)
+ std::string msg = MessageTypeStringSp[details.type];
+ if (target.type == MessageTarget::TYPE_USER)
{
- User* destuser = static_cast<User*>(dest);
+ User* destuser = target.Get<User>();
msg.append(destuser->nick);
}
- else if (target_type == TYPE_CHANNEL)
+ else if (target.type == MessageTarget::TYPE_CHANNEL)
{
- if (status)
- msg.push_back(status);
+ if (target.status)
+ msg.push_back(target.status);
- Channel* chan = static_cast<Channel*>(dest);
+ Channel* chan = target.Get<Channel>();
msg.append(chan->name);
}
else
{
- const char* servername = static_cast<const char*>(dest);
- msg.append(servername);
+ const std::string* servername = target.Get<std::string>();
+ msg.append(*servername);
}
- msg.append(" :").append(text);
+ msg.append(" :").append(details.echooriginal ? details.originaltext : details.text);
user->WriteFrom(user, msg);
}
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 9d2e0e681..36f2c923b 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -118,12 +118,12 @@ class ModuleMsgFlood : public Module
{
}
- ModResult OnUserPreMessage(User* user, void* voiddest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type != TYPE_CHANNEL)
+ if (target.type != MessageTarget::TYPE_CHANNEL)
return MOD_RES_PASSTHRU;
- Channel* dest = static_cast<Channel*>(voiddest);
+ Channel* dest = target.Get<Channel>();
if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf))
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp
index c9caf6a6a..045666f89 100644
--- a/src/modules/m_muteban.cpp
+++ b/src/modules/m_muteban.cpp
@@ -28,12 +28,12 @@ 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, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (!IS_LOCAL(user) || target_type != TYPE_CHANNEL)
+ if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_CHANNEL)
return MOD_RES_PASSTHRU;
- Channel* chan = static_cast<Channel*>(dest);
+ Channel* chan = target.Get<Channel>();
if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
{
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're muted)");
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index e9733cf54..26077759a 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -39,12 +39,12 @@ 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, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
+ if ((target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user)))
{
- Channel* c = (Channel*)dest;
- if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ", 8)) || (text == "\1ACTION\1") || (text == "\1ACTION"))
+ Channel* c = target.Get<Channel>();
+ if ((details.text.empty()) || (details.text[0] != '\001') || (!strncmp(details.text.c_str(),"\1ACTION ", 8)) || (details.text == "\1ACTION\1") || (details.text == "\1ACTION"))
return MOD_RES_PASSTHRU;
ModResult res = CheckExemption::Call(exemptionprov, user, c, "noctcp");
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index d7ea32d2f..77b0c9aa3 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -39,12 +39,12 @@ class ModuleNoNotice : public Module
tokens["EXTBAN"].push_back('T');
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
ModResult res;
- if ((msgtype == MSG_NOTICE) && (target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
+ if ((details.type == MSG_NOTICE) && (target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user)))
{
- Channel* c = (Channel*)dest;
+ Channel* c = target.Get<Channel>();
if (!c->GetExtBanStatus(user, 'T').check(!c->IsModeSet(nt)))
{
res = CheckExemption::Call(exemptionprov, user, c, "nonotice");
diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp
index 75105ca0d..a57e96740 100644
--- a/src/modules/m_repeat.cpp
+++ b/src/modules/m_repeat.cpp
@@ -355,12 +355,12 @@ class RepeatModule : public Module
rm.ReadConfig();
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type != TYPE_CHANNEL || !IS_LOCAL(user))
+ if (target.type != MessageTarget::TYPE_CHANNEL || !IS_LOCAL(user))
return MOD_RES_PASSTHRU;
- Channel* chan = reinterpret_cast<Channel*>(dest);
+ Channel* chan = target.Get<Channel>();
ChannelSettings* settings = rm.ext.get(chan);
if (!settings)
return MOD_RES_PASSTHRU;
@@ -373,7 +373,7 @@ class RepeatModule : public Module
if (res == MOD_RES_ALLOW)
return MOD_RES_PASSTHRU;
- if (rm.MatchLine(memb, settings, text))
+ if (rm.MatchLine(memb, settings, details.text))
{
if (settings->Action == ChannelSettings::ACT_BLOCK)
{
diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp
index 8ca531ed5..16a9bae86 100644
--- a/src/modules/m_restrictmsg.cpp
+++ b/src/modules/m_restrictmsg.cpp
@@ -24,11 +24,11 @@
class ModuleRestrictMsg : public Module
{
public:
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if ((target_type == TYPE_USER) && (IS_LOCAL(user)))
+ if ((target.type == MessageTarget::TYPE_USER) && (IS_LOCAL(user)))
{
- User* u = (User*)dest;
+ User* u = target.Get<User>();
// message allowed if:
// (1) the sender is opered
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 05cc2b416..6b5f5dacd 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -188,7 +188,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
m5.RemoveMode(user);
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
@@ -196,9 +196,9 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
std::string *account = accountname.get(user);
bool is_registered = account && !account->empty();
- if (target_type == TYPE_CHANNEL)
+ if (target.type == MessageTarget::TYPE_CHANNEL)
{
- Channel* c = (Channel*)dest;
+ Channel* c = target.Get<Channel>();
ModResult res = CheckExemption::Call(exemptionprov, user, c, "regmoderated");
if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW)
@@ -208,9 +208,9 @@ class ModuleServicesAccount : public Module, public Whois::EventListener
return MOD_RES_DENY;
}
}
- else if (target_type == TYPE_USER)
+ else if (target.type == MessageTarget::TYPE_USER)
{
- User* u = (User*)dest;
+ User* u = target.Get<User>();
if (u->IsModeSet(m3) && !is_registered)
{
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index edcc77468..0aa957e1d 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -332,16 +332,16 @@ class ModuleSilence : public Module
}
}
- ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target_type == TYPE_USER && IS_LOCAL(((User*)dest)))
+ if (target.type == MessageTarget::TYPE_USER && IS_LOCAL(target.Get<User>()))
{
- return MatchPattern((User*)dest, user, ((msgtype == MSG_PRIVMSG) ? SILENCE_PRIVATE : SILENCE_NOTICE));
+ return MatchPattern(target.Get<User>(), user, ((details.type == MSG_PRIVMSG) ? SILENCE_PRIVATE : SILENCE_NOTICE));
}
- else if (target_type == TYPE_CHANNEL)
+ else if (target.type == MessageTarget::TYPE_CHANNEL)
{
- Channel* chan = (Channel*)dest;
- BuildExemptList(msgtype, chan, user, exempt_list);
+ Channel* chan = target.Get<Channel>();
+ BuildExemptList(details.type, chan, user, details.exemptions);
}
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index c244629c1..1a77237bd 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -386,33 +386,33 @@ void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std:
CommandFTopic::Builder(user, chan).Broadcast();
}
-void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype)
+void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details)
{
if (!IS_LOCAL(user))
return;
- const char* message_type = (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
- if (target_type == TYPE_USER)
+ const char* message_type = (details.type == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
+ if (target.type == MessageTarget::TYPE_USER)
{
- User* d = (User*) dest;
+ User* d = target.Get<User>();
if (!IS_LOCAL(d))
{
CmdBuilder params(user, message_type);
params.push_back(d->uuid);
- params.push_last(text);
+ params.push_last(details.text);
params.Unicast(d);
}
}
- else if (target_type == TYPE_CHANNEL)
+ else if (target.type == MessageTarget::TYPE_CHANNEL)
{
- Utils->SendChannelMessage(user->uuid, (Channel*)dest, text, status, exempt_list, message_type);
+ Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.exemptions, message_type);
}
- else if (target_type == TYPE_SERVER)
+ else if (target.type == MessageTarget::TYPE_SERVER)
{
- char* target = (char*) dest;
+ const std::string* serverglob = target.Get<std::string>();
CmdBuilder par(user, message_type);
- par.push_back(target);
- par.push_last(text);
+ par.push_back(*serverglob);
+ par.push_last(details.text);
par.Broadcast();
}
}
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 13bab4cff..4eefb01a0 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -147,7 +147,7 @@ class ModuleSpanningTree : public Module
void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE;
ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE;
void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) 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 OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) 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 8068d8b7e..3699fc3aa 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -41,20 +41,20 @@ 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, MessageType msgtype) CXX11_OVERRIDE
+ ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
bool active = false;
- if (target_type == TYPE_USER)
+ if (target.type == MessageTarget::TYPE_USER)
{
- User* t = (User*)dest;
+ User* t = target.Get<User>();
active = t->IsModeSet(usc);
}
- else if (target_type == TYPE_CHANNEL)
+ else if (target.type == MessageTarget::TYPE_CHANNEL)
{
- Channel* t = (Channel*)dest;
+ Channel* t = target.Get<Channel>();
ModResult res = CheckExemption::Call(exemptionprov, user, t, "stripcolor");
if (res == MOD_RES_ALLOW)
@@ -65,7 +65,7 @@ class ModuleStripColor : public Module
if (active)
{
- InspIRCd::StripColor(text);
+ InspIRCd::StripColor(details.text);
}
return MOD_RES_PASSTHRU;