]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_timedbans.cpp
Clarify handshake failure messages
[user/henk/code/inspircd.git] / src / modules / m_timedbans.cpp
index 31896bfcba0d5e7b79d23dae56dac7e5e52dd845..8e045360e1f5182ccc86ccd91dbfc7ef5ac85cb9 100644 (file)
@@ -17,7 +17,7 @@
 
 /** Holds a timed ban
  */
-class TimedBan : public classbase
+class TimedBan
 {
  public:
        std::string channel;
@@ -33,9 +33,8 @@ timedbans TimedBanList;
 class CommandTban : public Command
 {
  public:
-       CommandTban (InspIRCd* Instance) : Command(Instance,"TBAN", 0, 3)
+       CommandTban(Module* Creator) : Command(Creator,"TBAN", 3)
        {
-               this->source = "m_timedbans.so";
                syntax = "<channel> <duration> <banmask>";
                TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END);
        }
@@ -45,8 +44,8 @@ class CommandTban : public Command
                Channel* channel = ServerInstance->FindChan(parameters[0]);
                if (channel)
                {
-                       int cm = channel->GetStatus(user);
-                       if ((cm == STATUS_HOP) || (cm == STATUS_OP))
+                       int cm = channel->GetPrefixValue(user);
+                       if ((cm == HALFOP_VALUE) || (cm == OP_VALUE))
                        {
                                if (!ServerInstance->IsValidMask(parameters[2]))
                                {
@@ -92,30 +91,33 @@ class CommandTban : public Command
                                        TimedBanList.push_back(T);
                                        channel->WriteAllExcept(user, true, '@', tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration);
                                        ServerInstance->PI->SendChannelNotice(channel, '@', user->nick + " added a timed ban on " + mask + " lasting for " + ConvToStr(duration) + " seconds.");
-                                       if (ServerInstance->Config->AllowHalfop)
-                                       {
-                                               channel->WriteAllExcept(user, true, '%', tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration);
-                                               ServerInstance->PI->SendChannelNotice(channel, '%', user->nick + " added a timed ban on " + mask + " lasting for " + ConvToStr(duration) + " seconds.");
-                                       }
                                        return CMD_SUCCESS;
                                }
                                return CMD_FAILURE;
                        }
-                       else user->WriteNumeric(482, "%s %s :You must be at least a%soperator to change modes on this channel",user->nick.c_str(), channel->name.c_str(),
-                                       ServerInstance->Config->AllowHalfop ? " half-" : " channel ");
+                       else
+                       {
+                               user->WriteNumeric(482, "%s %s :You do not have permission to change modes on this channel",
+                                       user->nick.c_str(), channel->name.c_str());
+                       }
                        return CMD_FAILURE;
                }
                user->WriteNumeric(401, "%s %s :No such channel",user->nick.c_str(), parameters[0].c_str());
                return CMD_FAILURE;
        }
+
+       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       {
+               return ROUTE_BROADCAST;
+       }
 };
 
 class ModuleTimedBans : public Module
 {
        CommandTban cmd;
  public:
-       ModuleTimedBans(InspIRCd* Me)
-               : Module(Me), cmd(Me)
+       ModuleTimedBans()
+               : cmd(this)
        {
                ServerInstance->AddCommand(&cmd);
                TimedBanList.clear();
@@ -128,7 +130,7 @@ class ModuleTimedBans : public Module
                TimedBanList.clear();
        }
 
-       virtual int OnDelBan(User* source, Channel* chan, const std::string &banmask)
+       virtual ModResult OnDelBan(User* source, Channel* chan, const std::string &banmask)
        {
                irc::string listitem = banmask.c_str();
                irc::string thischan = chan->name.c_str();
@@ -142,7 +144,7 @@ class ModuleTimedBans : public Module
                                break;
                        }
                }
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
        virtual void OnBackgroundTimer(time_t curtime)
@@ -166,11 +168,6 @@ class ModuleTimedBans : public Module
                                        std::string expiry = "*** Timed ban on " + chan + " expired.";
                                        cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
                                        ServerInstance->PI->SendChannelNotice(cr, '@', expiry);
-                                       if (ServerInstance->Config->AllowHalfop)
-                                       {
-                                               cr->WriteAllExcept(ServerInstance->FakeClient, true, '%', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
-                                               ServerInstance->PI->SendChannelNotice(cr, '%', expiry);
-                                       }
 
                                        ServerInstance->SendMode(setban, ServerInstance->FakeClient);
                                        ServerInstance->PI->SendMode(chan, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate());
@@ -183,7 +180,7 @@ class ModuleTimedBans : public Module
 
        virtual Version GetVersion()
        {
-               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("Adds timed bans", VF_COMMON | VF_VENDOR);
        }
 };