X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_timedbans.cpp;h=29691b338b54161f6e0dcf6d7b9707f9696ab142;hb=67de413cad88194972d55a8ff88464370890c5a9;hp=81b12d8816a99db076f5e8c1453df79c52b0a360;hpb=9fc218c005543384bcad73747a0574c8c6ab6289;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 81b12d881..29691b338 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -20,8 +20,6 @@ */ -/* $ModDesc: Adds timed bans */ - #include "inspircd.h" /** Holds a timed ban @@ -45,7 +43,6 @@ class CommandTban : public Command CommandTban(Module* Creator) : Command(Creator,"TBAN", 3) { syntax = " "; - TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END); } CmdResult Handle (const std::vector ¶meters, User *user) @@ -70,7 +67,7 @@ class CommandTban : public Command unsigned long expire = duration + ServerInstance->Time(); if (duration < 1) { - user->WriteServ("NOTICE "+user->nick+" :Invalid ban time"); + user->WriteNotice("Invalid ban time"); return CMD_FAILURE; } std::string mask = parameters[2]; @@ -80,20 +77,17 @@ class CommandTban : public Command bool isextban = ((mask.size() > 2) && (mask[1] == ':')); if (!isextban && !ServerInstance->IsValidMask(mask)) mask.append("!*@*"); - if ((mask.length() > 250) || (!ServerInstance->IsValidMask(mask) && !isextban)) + + setban.push_back(mask); + // Pass the user (instead of ServerInstance->FakeClient) to ModeHandler::Process() to + // make it so that the user sets the mode themselves + ServerInstance->Modes->Process(setban, user); + if (ServerInstance->Modes->GetLastParse().empty()) { - user->WriteServ("NOTICE "+user->nick+" :Invalid ban mask"); + user->WriteNotice("Invalid ban mask"); 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: + CUList tmp; T.channel = channelname; T.mask = mask; @@ -118,11 +112,11 @@ class BanWatcher : public ModeWatcher { public: BanWatcher(Module* parent) - : ModeWatcher(parent, 'b', MODETYPE_CHANNEL) + : ModeWatcher(parent, "ban", MODETYPE_CHANNEL) { } - void AfterMode(User* source, User* dest, Channel* chan, const std::string& banmask, bool adding, ModeType type) + void AfterMode(User* source, User* dest, Channel* chan, const std::string& banmask, bool adding) { if (adding) return; @@ -154,11 +148,9 @@ class ModuleTimedBans : public Module { } - void init() + void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(cmd); - Implementation eventlist[] = { I_OnBackgroundTimer }; - ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); ServerInstance->Modes->AddModeWatcher(&banwatcher); } @@ -167,7 +159,7 @@ class ModuleTimedBans : public Module ServerInstance->Modes->DelModeWatcher(&banwatcher); } - virtual void OnBackgroundTimer(time_t curtime) + void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE { timedbans expired; for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end();) @@ -198,12 +190,12 @@ class ModuleTimedBans : public Module cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str()); ServerInstance->PI->SendChannelNotice(cr, '@', expiry); - ServerInstance->SendGlobalMode(setban, ServerInstance->FakeClient); + ServerInstance->Modes->Process(setban, ServerInstance->FakeClient); } } } - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Adds timed bans", VF_COMMON | VF_VENDOR); }