diff options
author | Adam <Adam@anope.org> | 2012-12-27 11:06:00 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-12-27 11:06:00 -0500 |
commit | 4ab8a70b219608ffb4ebd0838f7f696ad1c48d65 (patch) | |
tree | 4aa3d4f0b6ca60bf41c8923a43fc93650b942dd8 /modules/commands/cs_tban.cpp | |
parent | c88a3fffd5f99c4927f1d14e119650e14d5c921b (diff) |
Add an expiry option to /cs ban
Diffstat (limited to 'modules/commands/cs_tban.cpp')
-rw-r--r-- | modules/commands/cs_tban.cpp | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/modules/commands/cs_tban.cpp b/modules/commands/cs_tban.cpp deleted file mode 100644 index 40fdfedb9..000000000 --- a/modules/commands/cs_tban.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* cs_tban.c - Bans the user for a given length of time - * - * (C) 2003-2012 Anope Team - * Contact us at team@anope.org - * - * Based on the original module by Rob <rob@anope.org> - * Included in the Anope module pack since Anope 1.7.8 - * Anope Coder: Rob <rob@anope.org> - * - * Please read COPYING and README for further details. - * - * Send bug reports to the Anope Coder instead of the module - * author, because any changes since the inclusion into anope - * are not supported by the original author. - */ -/*************************************************************************/ - -#include "module.h" - -static Module *me; - -class TempBan : public CallBack -{ - private: - Reference<Channel> chan; - Anope::string mask; - - public: - TempBan(time_t seconds, Channel *c, const Anope::string &banmask) : CallBack(me, seconds), chan(c), mask(banmask) { } - - void Tick(time_t ctime) anope_override - { - if (chan && chan->ci) - chan->RemoveMode(NULL, CMODE_BAN, mask); - } -}; - -class CommandCSTBan : public Command -{ - public: - CommandCSTBan(Module *creator) : Command(creator, "chanserv/tban", 3, 3) - { - this->SetDesc(_("Bans the user for a given length of time")); - this->SetSyntax(_("\037channel\037 \037nick\037 \037time\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Channel *c = Channel::Find(params[0]); - - const Anope::string &nick = params[1]; - const Anope::string &time = params[2]; - - User *u2; - if (!c) - source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); - else if (!c->ci) - source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); - else if (!source.AccessFor(c->ci).HasPriv("BAN")) - source.Reply(ACCESS_DENIED); - else if (!(u2 = User::Find(nick, true))) - source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); - else if (c->MatchesList(u2, CMODE_EXCEPT)) - source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), c->ci->name.c_str()); - else if (u2->IsProtected()) - source.Reply(ACCESS_DENIED); - else - { - time_t t = Anope::DoTime(time); - Anope::string mask = c->ci->GetIdealBan(u2); - c->SetMode(NULL, CMODE_BAN, mask); - new TempBan(t, c, mask); - - Log(LOG_COMMAND, source, this, c->ci) << "for " << mask << " to expire in " << Anope::Duration(t); - - source.Reply(_("%s banned from %s, will auto-expire in %s."), mask.c_str(), c->name.c_str(), Anope::Duration(t).c_str()); - } - - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override - { - this->OnSyntaxError(source, ""); - source.Reply(" "); - source.Reply(_("Bans the user for a given length of time.\n" - " \n" - "Bans the given user from a channel for a specified length of\n" - "time. If the ban is removed before by hand, it\n" - "will NOT be replaced.")); - - return true; - } -}; - -class CSTBan : public Module -{ - CommandCSTBan commandcstban; - - public: - CSTBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), commandcstban(this) - { - this->SetAuthor("Anope"); - me = this; - } -}; - -MODULE_INIT(CSTBan) |