]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/cmode_b.cpp
2.0.5 release
[user/henk/code/inspircd.git] / src / modes / cmode_b.cpp
index 415d33c30247152cb7ec8da3b4b7e6c0c631efa1..0bd8d286d698540bea17d6e1e865b9482019c2bc 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
 #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)
 {
-       int status = channel->GetStatus(source);
+       int status = channel->GetPrefixValue(source);
        /* Call the correct method depending on wether we're adding or removing the mode */
        if (adding)
        {
@@ -104,7 +105,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();
@@ -115,9 +116,9 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan
                return dest;
        }
 
-       int MOD_RESULT = 0;
-       FOREACH_RESULT(I_OnAddBan,OnAddBan(user,chan,dest));
-       if (MOD_RESULT)
+       ModResult MOD_RESULT;
+       FIRST_MOD_RESULT(OnAddBan, MOD_RESULT, (user,chan,dest));
+       if (MOD_RESULT == MOD_RES_DENY)
        {
                dest = "";
                return dest;
@@ -140,18 +141,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,16 +150,13 @@ 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()))
                {
-                       int MOD_RESULT = 0;
-                       FOREACH_RESULT(I_OnDelBan,OnDelBan(user, chan, dest));
-                       if (MOD_RESULT)
+                       ModResult MOD_RESULT;
+                       FIRST_MOD_RESULT(OnDelBan, MOD_RESULT, (user, chan, dest));
+                       if (MOD_RESULT == MOD_RES_DENY)
                        {
                                dest = "";
                                return dest;