summaryrefslogtreecommitdiff
path: root/src/modules/m_timedbans.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-04-13 15:48:00 +0200
committerAttila Molnar <attilamolnar@hush.com>2015-04-13 15:48:00 +0200
commitb7526f6efd47ed87dc67adfa70f09c9b83adf9a8 (patch)
tree96aa9a66af14316077bf37d0d7eee688431474a2 /src/modules/m_timedbans.cpp
parent0243179509eb8a561b62c7845dc1322fcd94654a (diff)
m_timedbans Extract IsBanSet() to a function
Diffstat (limited to 'src/modules/m_timedbans.cpp')
-rw-r--r--src/modules/m_timedbans.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index ef1ae4c48..754b4c3a0 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -42,6 +42,16 @@ timedbans TimedBanList;
*/
class CommandTban : public Command
{
+ static bool IsBanSet(Channel* chan, const std::string& mask)
+ {
+ for (BanList::const_iterator i = chan->bans.begin(); i != chan->bans.end(); ++i)
+ {
+ if (!strcasecmp(i->data.c_str(), mask.c_str()))
+ return true;
+ }
+ return false;
+ }
+
public:
CommandTban(Module* Creator) : Command(Creator,"TBAN", 3)
{
@@ -90,11 +100,9 @@ class CommandTban : public Command
// use CallHandler to make it so that the user sets the mode
// themselves
ServerInstance->Parser->CallHandler("MODE",setban,user);
- for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
- if (!strcasecmp(i->data.c_str(), mask.c_str()))
- goto found;
- return CMD_FAILURE;
-found:
+ if (!IsBanSet(channel, mask))
+ return CMD_FAILURE;
+
CUList tmp;
T.channel = channelname;
T.mask = mask;