]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_timedbans.cpp
Fix dccallow to work with files with spaces in their names
[user/henk/code/inspircd.git] / src / modules / m_timedbans.cpp
index ef1ae4c48abe9601868664e05b9cc8c89b33113a..b473277046c0af470fbd3afea566c89711090711 100644 (file)
@@ -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)
        {
@@ -86,15 +96,20 @@ class CommandTban : public Command
                        user->WriteServ("NOTICE "+user->nick+" :Invalid ban mask");
                        return CMD_FAILURE;
                }
+
+               if (IsBanSet(channel, mask))
+               {
+                       user->WriteServ("NOTICE %s :Ban already set", user->nick.c_str());
+                       return CMD_FAILURE;
+               }
+
                setban.push_back(mask);
                // 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;