X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_timedbans.cpp;h=e3a93833686355ad265ea950049e964d6e50b0f4;hb=f62654a6859998f9d63eb22702c572d5ebcff15c;hp=a76d89c827d0efc5bf36cdad4001fb82162e8832;hpb=d9d99cd02dadf34bfcc220734ba0c422f0acb3e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index a76d89c82..e3a938336 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) @@ -53,14 +50,14 @@ class CommandTban : public Command Channel* channel = ServerInstance->FindChan(parameters[0]); if (!channel) { - user->WriteNumeric(401, "%s %s :No such channel",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such channel", parameters[0].c_str()); return CMD_FAILURE; } int cm = channel->GetPrefixValue(user); if (cm < HALFOP_VALUE) { - user->WriteNumeric(482, "%s %s :You do not have permission to set bans on this channel", - user->nick.c_str(), channel->name.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have permission to set bans on this channel", + channel->name.c_str()); return CMD_FAILURE; } @@ -78,13 +75,13 @@ class CommandTban : public Command setban.push_back(parameters[0]); setban.push_back("+b"); bool isextban = ((mask.size() > 2) && (mask[1] == ':')); - if (!isextban && !ServerInstance->IsValidMask(mask)) + if (!isextban && !InspIRCd::IsValidMask(mask)) mask.append("!*@*"); setban.push_back(mask); - // use CallHandler to make it so that the user sets the mode - // themselves - ServerInstance->Parser->CallHandler("MODE",setban,user); + // 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->WriteNotice("Invalid ban mask"); @@ -151,19 +148,6 @@ class ModuleTimedBans : public Module { } - 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); - } - - ~ModuleTimedBans() - { - ServerInstance->Modes->DelModeWatcher(&banwatcher); - } - void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE { timedbans expired; @@ -195,7 +179,7 @@ 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); } } }