]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/cmode_b.cpp
Merge pull request #96 from Justasic/insp20
[user/henk/code/inspircd.git] / src / modes / cmode_b.cpp
index 9c9c2129cb05ec393e904511e1f19384c5d48afd..034a93a859feeba9b85f04d9677edfe4b1c550a7 100644 (file)
@@ -1,16 +1,23 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
 #include <string>
 #include <vector>
@@ -25,8 +32,9 @@
 #include "hashcomp.h"
 #include "modes/cmode_b.h"
 
-ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(Instance, NULL, 'b', 1, 1, true, MODETYPE_CHANNEL, false)
+ModeChannelBan::ModeChannelBan() : ModeHandler(NULL, "ban", 'b', PARAM_ALWAYS, MODETYPE_CHANNEL)
 {
+       list = true;
 }
 
 ModeAction ModeChannelBan::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
@@ -104,7 +112,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan
        /* Attempt to tidy the mask */
        ModeParser::CleanMask(dest);
        /* If the mask was invalid, we exit */
-       if (dest == "")
+       if (dest == "" || dest.length() > 250)
                return dest;
 
        long maxbans = chan->GetMaxBans();
@@ -116,7 +124,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan
        }
 
        ModResult MOD_RESULT;
-       FIRST_MOD_RESULT(ServerInstance, OnAddBan, MOD_RESULT, (user,chan,dest));
+       FIRST_MOD_RESULT(OnAddBan, MOD_RESULT, (user,chan,dest));
        if (MOD_RESULT == MOD_RES_DENY)
        {
                dest = "";
@@ -140,18 +148,6 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan
        return dest;
 }
 
-ModePair ModeChannelBan::ModeSet(User*, User*, Channel* channel, const std::string &parameter)
-{
-       for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
-       {
-               if (!strcasecmp(i->data.c_str(), parameter.c_str()))
-               {
-                       return std::make_pair(true, i->data);
-               }
-       }
-       return std::make_pair(false, parameter);
-}
-
 std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan, int)
 {
        if ((!user) || (!chan))
@@ -161,15 +157,12 @@ std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan
                return dest;
        }
 
-       /* 'Clean' the mask, e.g. nick -> nick!*@* */
-       ModeParser::CleanMask(dest);
-
        for (BanList::iterator i = chan->bans.begin(); i != chan->bans.end(); i++)
        {
                if (!strcasecmp(i->data.c_str(), dest.c_str()))
                {
                        ModResult MOD_RESULT;
-                       FIRST_MOD_RESULT(ServerInstance, OnDelBan, MOD_RESULT, (user, chan, dest));
+                       FIRST_MOD_RESULT(OnDelBan, MOD_RESULT, (user, chan, dest));
                        if (MOD_RESULT == MOD_RES_DENY)
                        {
                                dest = "";