aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-05-08 16:31:38 +0100
committerGravatar Sadie Powell2021-05-08 17:16:11 +0100
commit6a2f6331eddd5a89ff02643f72e93151dab15547 (patch)
tree0c8a672e4a461fe0d743a6d181b01c961d992df6 /src
parentConstify ChannelManager::Find. (diff)
downloadinspircd++-6a2f6331eddd5a89ff02643f72e93151dab15547.tar.gz
inspircd++-6a2f6331eddd5a89ff02643f72e93151dab15547.tar.bz2
inspircd++-6a2f6331eddd5a89ff02643f72e93151dab15547.zip
Add ChannelManager::IsPrefix.
Diffstat (limited to 'src')
-rw-r--r--src/channelmanager.cpp7
-rw-r--r--src/coremods/core_message.cpp2
-rw-r--r--src/coremods/core_mode.cpp2
-rw-r--r--src/mode.cpp2
-rw-r--r--src/modules/m_blockamsg.cpp4
-rw-r--r--src/modules/m_channames.cpp2
-rw-r--r--src/modules/m_filter.cpp2
-rw-r--r--src/modules/m_ircv3_ctctags.cpp2
-rw-r--r--src/modules/m_remove.cpp2
-rw-r--r--src/modules/m_samode.cpp2
-rw-r--r--src/modules/m_spanningtree/metadata.cpp2
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/modules/m_sslinfo.cpp2
13 files changed, 19 insertions, 14 deletions
diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp
index 4b77cff14..9c6137147 100644
--- a/src/channelmanager.cpp
+++ b/src/channelmanager.cpp
@@ -24,7 +24,7 @@ bool ChannelManager::DefaultIsChannel(const std::string& channel)
if (channel.empty() || channel.length() > ServerInstance->Config->Limits.MaxChannel)
return false;
- if (channel[0] != '#')
+ if (!ServerInstance->Channels.IsPrefix(channel[0]))
return false;
for (const auto& chr : insp::iterator_range(channel.begin() + 1, channel.end()))
@@ -50,3 +50,8 @@ Channel* ChannelManager::Find(const std::string& channel) const
return iter->second;
}
+bool ChannelManager::IsPrefix(unsigned char prefix) const
+{
+ // TODO: implement support for multiple channel types.
+ return prefix == '#';
+}
diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp
index 1b18a231b..2cc0539a9 100644
--- a/src/coremods/core_message.cpp
+++ b/src/coremods/core_message.cpp
@@ -313,7 +313,7 @@ class CommandMessage : public Command
}
// The target is a channel name.
- if (*target == '#')
+ if (ServerInstance->Channels.IsPrefix(*target))
return HandleChannelTarget(user, parameters, target, targetpfx);
// The target is a nickname.
diff --git a/src/coremods/core_mode.cpp b/src/coremods/core_mode.cpp
index dee6be6bb..71cb4afd5 100644
--- a/src/coremods/core_mode.cpp
+++ b/src/coremods/core_mode.cpp
@@ -97,7 +97,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters)
if ((!targetchannel || !CanSeeChan(user, targetchannel)) && (!targetuser))
{
- if (target[0] == '#')
+ if (ServerInstance->Channels.IsPrefix(target[0]))
user->WriteNumeric(Numerics::NoSuchChannel(target));
else
user->WriteNumeric(Numerics::NoSuchNick(target));
diff --git a/src/mode.cpp b/src/mode.cpp
index cdfc4b8d0..ea3e64eb6 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -585,7 +585,7 @@ void ModeParser::AddMode(ModeHandler* mh)
PrefixMode* pm = mh->IsPrefixMode();
if (pm)
{
- if ((pm->GetPrefix() > 126) || (pm->GetPrefix() == ',') || (pm->GetPrefix() == ':') || (pm->GetPrefix() == '#'))
+ if ((pm->GetPrefix() > 126) || (pm->GetPrefix() == ',') || (pm->GetPrefix() == ':') || ServerInstance->Channels.IsPrefix(pm->GetPrefix()))
throw ModuleException(InspIRCd::Format("Mode prefix for %s is invalid: %c",
mh->name.c_str(), pm->GetPrefix()));
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 2d929b15d..f76f211bc 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -85,12 +85,12 @@ class ModuleBlockAmsg : public Module
// parameters[0] is the target list, count how many channels are there
unsigned int targets = 0;
// Is the first target a channel?
- if (*parameters[0].c_str() == '#')
+ if (ServerInstance->Channels.IsPrefix(parameters[0][0]))
targets = 1;
for (const char* c = parameters[0].c_str(); *c; c++)
{
- if ((*c == ',') && (*(c+1) == '#'))
+ if (*c == ',' && ServerInstance->Channels.IsPrefix(*(c + 1)))
targets++;
}
diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp
index 353b50873..71c5efbb8 100644
--- a/src/modules/m_channames.cpp
+++ b/src/modules/m_channames.cpp
@@ -34,7 +34,7 @@ class NewIsChannelHandler
bool NewIsChannelHandler::Call(const std::string& channame)
{
- if (channame.empty() || channame.length() > ServerInstance->Config->Limits.MaxChannel || channame[0] != '#')
+ if (channame.empty() || channame.length() > ServerInstance->Config->Limits.MaxChannel || !ServerInstance->Channels.IsPrefix(channame[0]))
return false;
for (const auto& chr : channame)
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index a2be4a628..4759f42a1 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -625,7 +625,7 @@ void ModuleFilter::ReadConfig(ConfigStatus& status)
const std::string target = tag->getString("target");
if (!target.empty())
{
- if (target[0] == '#')
+ if (ServerInstance->Channels.IsPrefix(target[0]))
exemptedchans.insert(target);
else
exemptednicks.insert(target);
diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp
index b4cf560d9..358c2c7f3 100644
--- a/src/modules/m_ircv3_ctctags.cpp
+++ b/src/modules/m_ircv3_ctctags.cpp
@@ -249,7 +249,7 @@ class CommandTagMsg : public Command
}
// The target is a channel name.
- if (*target == '#')
+ if (ServerInstance->Channels.IsPrefix(*target))
return HandleChannelTarget(user, parameters, target, targetpfx);
// The target is a nickname.
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index ef9cdb789..5a570b3ad 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -61,7 +61,7 @@ class RemoveBase : public Command
std::string reason;
// If the command is a /REMOVE then detect the parameter order
- bool neworder = ((fpart) || (parameters[0][0] == '#'));
+ bool neworder = (fpart || ServerInstance->Channels.IsPrefix(parameters[0][0]));
/* Set these to the parameters needed, the new version of this module switches it's parameters around
* supplying a new command with the new order while keeping the old /remove with the older order.
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index c9a42b56f..fc65b083a 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -44,7 +44,7 @@ class CommandSamode : public Command
CmdResult Handle(User* user, const Params& parameters) override
{
- if (parameters[0].c_str()[0] != '#')
+ if (!ServerInstance->Channels.IsPrefix(parameters[0][0]))
{
User* target = ServerInstance->Users.FindNick(parameters[0]);
if ((!target) || (target->registered != REG_ALL))
diff --git a/src/modules/m_spanningtree/metadata.cpp b/src/modules/m_spanningtree/metadata.cpp
index f3bc66f77..f4c6c6beb 100644
--- a/src/modules/m_spanningtree/metadata.cpp
+++ b/src/modules/m_spanningtree/metadata.cpp
@@ -70,7 +70,7 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params)
FOREACH_MOD(OnDecodeMetaData, (m, params[5], value));
}
- if (params[0][0] == '#')
+ if (ServerInstance->Channels.IsPrefix(params[0][0]))
{
// Channel METADATA has an additional parameter: the channel TS
// :22D METADATA #channel 12345 extname :extdata
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index dc75d054c..195a8b558 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -95,7 +95,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
pfx = dest[0];
dest.erase(dest.begin());
}
- if (dest[0] == '#')
+ if (ServerInstance->Channels.IsPrefix(dest[0]))
{
Channel* c = ServerInstance->Channels.Find(dest);
if (!c)
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index d4db45d51..5985ca95e 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -259,7 +259,7 @@ class CommandSSLInfo : public SplitCommand
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override
{
- if (ServerInstance->Channels.IsChannel(parameters[0]))
+ if (ServerInstance->Channels.IsPrefix(parameters[0][0]))
return HandleChannel(user, parameters[0]);
else
return HandleUser(user, parameters[0]);