*/
-/* $ModDesc: Adds timed bans */
-
#include "inspircd.h"
/** Holds a timed ban
CommandTban(Module* Creator) : Command(Creator,"TBAN", 3)
{
syntax = "<channel> <duration> <banmask>";
- TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END);
}
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
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;
}
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");
{
}
- 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;