summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/m_deaf.cpp86
-rw-r--r--src/modules/m_filter.cpp37
-rw-r--r--src/modules/m_ircv3_echomessage.cpp82
-rw-r--r--src/modules/m_noctcp.cpp49
-rw-r--r--src/modules/m_services_account.cpp47
-rw-r--r--src/modules/m_silence.cpp52
-rw-r--r--src/modules/m_spanningtree/main.cpp48
-rw-r--r--src/modules/m_stripcolor.cpp33
8 files changed, 247 insertions, 187 deletions
diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp
index 90412c5c1..e360e2a2e 100644
--- a/src/modules/m_deaf.cpp
+++ b/src/modules/m_deaf.cpp
@@ -89,50 +89,58 @@ class ModuleDeaf : public Module
ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
{
- if (target.type == MessageTarget::TYPE_CHANNEL)
+ switch (target.type)
{
- 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)
- // Then it is obviously going to get through +d, no exemption list required
- if (deaf_bypasschars_uline.empty() && is_bypasschar)
- return MOD_RES_PASSTHRU;
- // If it matches both bypasschar and bypasschar_uline, it will get through.
- if (is_bypasschar && is_bypasschar_uline)
- return MOD_RES_PASSTHRU;
-
- const Channel::MemberMap& ulist = chan->GetUsers();
- for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i)
+ case MessageTarget::TYPE_CHANNEL:
{
- // not +d
- if (!i->first->IsModeSet(deafmode))
- continue;
-
- bool is_a_uline = i->first->server->IsULine();
- // matched a U-line only bypass
- if (is_bypasschar_uline && is_a_uline)
- continue;
- // matched a regular bypass
- if (is_bypasschar && !is_a_uline)
- continue;
-
- // don't deliver message!
- details.exemptions.insert(i->first);
+ 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)
+ // Then it is obviously going to get through +d, no exemption list required
+ if (deaf_bypasschars_uline.empty() && is_bypasschar)
+ return MOD_RES_PASSTHRU;
+ // If it matches both bypasschar and bypasschar_uline, it will get through.
+ if (is_bypasschar && is_bypasschar_uline)
+ return MOD_RES_PASSTHRU;
+
+ const Channel::MemberMap& ulist = chan->GetUsers();
+ for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i)
+ {
+ // not +d
+ if (!i->first->IsModeSet(deafmode))
+ continue;
+
+ bool is_a_uline = i->first->server->IsULine();
+ // matched a U-line only bypass
+ if (is_bypasschar_uline && is_a_uline)
+ continue;
+ // matched a regular bypass
+ if (is_bypasschar && !is_a_uline)
+ continue;
+
+ // don't deliver message!
+ details.exemptions.insert(i->first);
+ }
+ break;
}
- }
- else if (target.type == MessageTarget::TYPE_USER)
- {
- User* targ = target.Get<User>();
- if (!targ->IsModeSet(privdeafmode))
- return MOD_RES_PASSTHRU;
+ case MessageTarget::TYPE_USER:
+ {
+ User* targ = target.Get<User>();
+ if (!targ->IsModeSet(privdeafmode))
+ return MOD_RES_PASSTHRU;
- if (!privdeafuline && user->server->IsULine())
- return MOD_RES_DENY;
+ if (!privdeafuline && user->server->IsULine())
+ return MOD_RES_DENY;
- if (!user->HasPrivPermission("users/ignore-privdeaf"))
- return MOD_RES_DENY;
+ if (!user->HasPrivPermission("users/ignore-privdeaf"))
+ return MOD_RES_DENY;
+
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ break;
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 8e51fd683..e7aab2eeb 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -372,25 +372,32 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
{
bool is_selfmsg = false;
std::string target;
- if (msgtarget.type == MessageTarget::TYPE_USER)
+ switch (msgtarget.type)
{
- 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;
+ case MessageTarget::TYPE_USER:
+ {
+ 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;
- if (user == t)
- is_selfmsg = true;
+ if (user == t)
+ is_selfmsg = true;
- target = t->nick;
- }
- else if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
- {
- Channel* t = msgtarget.Get<Channel>();
- if (exemptedchans.count(t->name))
- return MOD_RES_PASSTHRU;
+ target = t->nick;
+ break;
+ }
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Channel* t = msgtarget.Get<Channel>();
+ if (exemptedchans.count(t->name))
+ return MOD_RES_PASSTHRU;
- target = t->name;
+ target = t->name;
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ break;
}
if (is_selfmsg && warnonselfmsg)
diff --git a/src/modules/m_ircv3_echomessage.cpp b/src/modules/m_ircv3_echomessage.cpp
index 3ec534e91..8f281da70 100644
--- a/src/modules/m_ircv3_echomessage.cpp
+++ b/src/modules/m_ircv3_echomessage.cpp
@@ -48,26 +48,32 @@ class ModuleIRCv3EchoMessage
const std::string& text = details.echo_original ? details.original_text : details.text;
const ClientProtocol::TagMap& tags = details.echo_original ? details.tags_in : details.tags_out;
- if (target.type == MessageTarget::TYPE_USER)
+ switch (target.type)
{
- User* destuser = target.Get<User>();
- ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, destuser, text, details.type);
- privmsg.AddTags(tags);
- localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);
- }
- else if (target.type == MessageTarget::TYPE_CHANNEL)
- {
- Channel* chan = target.Get<Channel>();
- ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, chan, text, details.type, target.status);
- privmsg.AddTags(tags);
- localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);
- }
- else
- {
- const std::string* servername = target.Get<std::string>();
- ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, *servername, text, details.type);
- privmsg.AddTags(tags);
- localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);
+ case MessageTarget::TYPE_USER:
+ {
+ User* destuser = target.Get<User>();
+ ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, destuser, text, details.type);
+ privmsg.AddTags(tags);
+ localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);
+ break;
+ }
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Channel* chan = target.Get<Channel>();
+ ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, chan, text, details.type, target.status);
+ privmsg.AddTags(tags);
+ localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ {
+ const std::string* servername = target.Get<std::string>();
+ ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, user, *servername, text, details.type);
+ privmsg.AddTags(tags);
+ localuser->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);
+ break;
+ }
}
}
@@ -80,23 +86,29 @@ class ModuleIRCv3EchoMessage
LocalUser* const localuser = static_cast<LocalUser*>(user);
const ClientProtocol::TagMap& tags = details.echo_original ? details.tags_in : details.tags_out;
- if (target.type == MessageTarget::TYPE_USER)
- {
- User* destuser = target.Get<User>();
- CTCTags::TagMessage message(user, destuser, tags);
- localuser->Send(tagmsgprov, message);
- }
- else if (target.type == MessageTarget::TYPE_CHANNEL)
- {
- Channel* chan = target.Get<Channel>();
- CTCTags::TagMessage message(user, chan, tags);
- localuser->Send(tagmsgprov, message);
- }
- else
+ switch (target.type)
{
- const std::string* servername = target.Get<std::string>();
- CTCTags::TagMessage message(user, servername->c_str(), tags);
- localuser->Send(tagmsgprov, message);
+ case MessageTarget::TYPE_USER:
+ {
+ User* destuser = target.Get<User>();
+ CTCTags::TagMessage message(user, destuser, tags);
+ localuser->Send(tagmsgprov, message);
+ break;
+ }
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Channel* chan = target.Get<Channel>();
+ CTCTags::TagMessage message(user, chan, tags);
+ localuser->Send(tagmsgprov, message);
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ {
+ const std::string* servername = target.Get<std::string>();
+ CTCTags::TagMessage message(user, servername->c_str(), tags);
+ localuser->Send(tagmsgprov, message);
+ break;
+ }
}
}
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index c73f8308e..f288820b8 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -61,33 +61,40 @@ class ModuleNoCTCP : public Module
if (!details.IsCTCP(ctcpname) || irc::equals(ctcpname, "ACTION"))
return MOD_RES_PASSTHRU;
- if (target.type == MessageTarget::TYPE_CHANNEL)
+ switch (target.type)
{
- if (user->HasPrivPermission("channels/ignore-noctcp"))
- return MOD_RES_PASSTHRU;
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ if (user->HasPrivPermission("channels/ignore-noctcp"))
+ return MOD_RES_PASSTHRU;
- Channel* c = target.Get<Channel>();
- ModResult res = CheckExemption::Call(exemptionprov, user, c, "noctcp");
- if (res == MOD_RES_ALLOW)
- return MOD_RES_PASSTHRU;
+ Channel* c = target.Get<Channel>();
+ ModResult res = CheckExemption::Call(exemptionprov, user, c, "noctcp");
+ if (res == MOD_RES_ALLOW)
+ return MOD_RES_PASSTHRU;
- if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc)))
- {
- user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send CTCP to channel (+C is set)");
- return MOD_RES_DENY;
+ if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc)))
+ {
+ user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send CTCP to channel (+C is set)");
+ return MOD_RES_DENY;
+ }
+ break;
}
- }
- else if (target.type == MessageTarget::TYPE_USER)
- {
- if (user->HasPrivPermission("users/ignore-noctcp"))
- return MOD_RES_PASSTHRU;
-
- User* u = target.Get<User>();
- if (u->IsModeSet(ncu))
+ case MessageTarget::TYPE_USER:
{
- user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "Can't send CTCP to user (+T is set)");
- return MOD_RES_DENY;
+ if (user->HasPrivPermission("users/ignore-noctcp"))
+ return MOD_RES_PASSTHRU;
+
+ User* u = target.Get<User>();
+ if (u->IsModeSet(ncu))
+ {
+ user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "Can't send CTCP to user (+T is set)");
+ return MOD_RES_DENY;
+ }
+ break;
}
+ case MessageTarget::TYPE_SERVER:
+ break;
}
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 6e15aa8bf..72cd925ab 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -207,32 +207,39 @@ class ModuleServicesAccount
std::string *account = accountname.get(user);
bool is_registered = account && !account->empty();
- if (target.type == MessageTarget::TYPE_CHANNEL)
+ switch (target.type)
{
- Channel* targchan = target.Get<Channel>();
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Channel* targchan = target.Get<Channel>();
- if (!targchan->IsModeSet(m2) || is_registered)
- return MOD_RES_PASSTHRU;
+ if (!targchan->IsModeSet(m2) || is_registered)
+ return MOD_RES_PASSTHRU;
- if (CheckExemption::Call(exemptionprov, user, targchan, "regmoderated") == MOD_RES_ALLOW)
- return MOD_RES_PASSTHRU;
+ if (CheckExemption::Call(exemptionprov, user, targchan, "regmoderated") == MOD_RES_ALLOW)
+ return MOD_RES_PASSTHRU;
- // User is messaging a +M channel and is not registered or exempt.
- user->WriteNumeric(ERR_NEEDREGGEDNICK, targchan->name, "You need to be identified to a registered account to message this channel");
- return MOD_RES_DENY;
- }
- else if (target.type == MessageTarget::TYPE_USER)
- {
- User* targuser = target.Get<User>();
- if (!targuser->IsModeSet(m3) || is_registered)
- return MOD_RES_PASSTHRU;
+ // User is messaging a +M channel and is not registered or exempt.
+ user->WriteNumeric(ERR_NEEDREGGEDNICK, targchan->name, "You need to be identified to a registered account to message this channel");
+ return MOD_RES_DENY;
+ break;
+ }
+ case MessageTarget::TYPE_USER:
+ {
+ User* targuser = target.Get<User>();
+ if (!targuser->IsModeSet(m3) || is_registered)
+ return MOD_RES_PASSTHRU;
- if (calleridapi && calleridapi->IsOnAcceptList(user, targuser))
- return MOD_RES_PASSTHRU;
+ if (calleridapi && calleridapi->IsOnAcceptList(user, targuser))
+ return MOD_RES_PASSTHRU;
- // User is messaging a +R user and is not registered or on an accept list.
- user->WriteNumeric(ERR_NEEDREGGEDNICK, targuser->nick, "You need to be identified to a registered account to message this user");
- return MOD_RES_DENY;
+ // User is messaging a +R user and is not registered or on an accept list.
+ user->WriteNumeric(ERR_NEEDREGGEDNICK, targuser->nick, "You need to be identified to a registered account to message this user");
+ return MOD_RES_DENY;
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ break;
}
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 87b70dfa4..1e73bda27 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -384,32 +384,38 @@ class ModuleSilence
bool is_ctcp = details.IsCTCP(ctcpname) && !irc::equals(ctcpname, "ACTION");
SilenceEntry::SilenceFlags flag = SilenceEntry::SF_NONE;
- if (target.type == MessageTarget::TYPE_CHANNEL)
- {
- if (is_ctcp)
- flag = SilenceEntry::SF_CTCP_CHANNEL;
- else if (details.type == MSG_NOTICE)
- flag = SilenceEntry::SF_NOTICE_CHANNEL;
- else if (details.type == MSG_PRIVMSG)
- flag = SilenceEntry::SF_PRIVMSG_CHANNEL;
-
- return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions);
- }
-
- if (target.type == MessageTarget::TYPE_USER)
+ switch (target.type)
{
- if (is_ctcp)
- flag = SilenceEntry::SF_CTCP_USER;
- else if (details.type == MSG_NOTICE)
- flag = SilenceEntry::SF_NOTICE_USER;
- else if (details.type == MSG_PRIVMSG)
- flag = SilenceEntry::SF_PRIVMSG_USER;
-
- if (!CanReceiveMessage(user, target.Get<User>(), flag))
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ if (is_ctcp)
+ flag = SilenceEntry::SF_CTCP_CHANNEL;
+ else if (details.type == MSG_NOTICE)
+ flag = SilenceEntry::SF_NOTICE_CHANNEL;
+ else if (details.type == MSG_PRIVMSG)
+ flag = SilenceEntry::SF_PRIVMSG_CHANNEL;
+
+ return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions);
+ break;
+ }
+ case MessageTarget::TYPE_USER:
{
- details.echo_original = true;
- return MOD_RES_DENY;
+ if (is_ctcp)
+ flag = SilenceEntry::SF_CTCP_USER;
+ else if (details.type == MSG_NOTICE)
+ flag = SilenceEntry::SF_NOTICE_USER;
+ else if (details.type == MSG_PRIVMSG)
+ flag = SilenceEntry::SF_PRIVMSG_USER;
+
+ if (!CanReceiveMessage(user, target.Get<User>(), flag))
+ {
+ details.echo_original = true;
+ return MOD_RES_DENY;
+ }
+ break;
}
+ case MessageTarget::TYPE_SERVER:
+ break;
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index db5265344..1a51955d1 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -392,30 +392,36 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ
return;
const char* message_type = (details.type == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
- if (target.type == MessageTarget::TYPE_USER)
+ switch (target.type)
{
- User* d = target.Get<User>();
- if (!IS_LOCAL(d))
+ case MessageTarget::TYPE_USER:
{
- CmdBuilder params(user, message_type);
- params.push_tags(details.tags_out);
- params.push_back(d->uuid);
- params.push_last(details.text);
- params.Unicast(d);
+ User* d = target.Get<User>();
+ if (!IS_LOCAL(d))
+ {
+ CmdBuilder params(user, message_type);
+ params.push_tags(details.tags_out);
+ params.push_back(d->uuid);
+ params.push_last(details.text);
+ params.Unicast(d);
+ }
+ break;
+ }
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ {
+ const std::string* serverglob = target.Get<std::string>();
+ CmdBuilder par(user, message_type);
+ par.push_tags(details.tags_out);
+ par.push_back(*serverglob);
+ par.push_last(details.text);
+ par.Broadcast();
+ break;
}
- }
- else if (target.type == MessageTarget::TYPE_CHANNEL)
- {
- Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
- }
- else if (target.type == MessageTarget::TYPE_SERVER)
- {
- const std::string* serverglob = target.Get<std::string>();
- CmdBuilder par(user, message_type);
- par.push_tags(details.tags_out);
- par.push_back(*serverglob);
- par.push_last(details.text);
- par.Broadcast();
}
}
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 6ea279422..a309492eb 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -47,20 +47,27 @@ class ModuleStripColor : public Module
return MOD_RES_PASSTHRU;
bool active = false;
- if (target.type == MessageTarget::TYPE_USER)
+ switch (target.type)
{
- User* t = target.Get<User>();
- active = t->IsModeSet(usc);
- }
- else if (target.type == MessageTarget::TYPE_CHANNEL)
- {
- Channel* t = target.Get<Channel>();
- ModResult res = CheckExemption::Call(exemptionprov, user, t, "stripcolor");
-
- if (res == MOD_RES_ALLOW)
- return MOD_RES_PASSTHRU;
-
- active = !t->GetExtBanStatus(user, 'S').check(!t->IsModeSet(csc));
+ case MessageTarget::TYPE_USER:
+ {
+ User* t = target.Get<User>();
+ active = t->IsModeSet(usc);
+ break;
+ }
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Channel* t = target.Get<Channel>();
+ ModResult res = CheckExemption::Call(exemptionprov, user, t, "stripcolor");
+
+ if (res == MOD_RES_ALLOW)
+ return MOD_RES_PASSTHRU;
+
+ active = !t->GetExtBanStatus(user, 'S').check(!t->IsModeSet(csc));
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ break;
}
if (active)