diff options
Diffstat (limited to 'modules/extra')
35 files changed, 0 insertions, 3688 deletions
diff --git a/modules/extra/cs_appendtopic.cpp b/modules/extra/cs_appendtopic.cpp deleted file mode 100644 index c9af50613..000000000 --- a/modules/extra/cs_appendtopic.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* cs_appendtopic.c - Add text to a channels topic - * - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Based on the original module by SGR <Alex_SGR@ntlworld.com> - * Included in the Anope module pack since Anope 1.7.9 - * Anope Coder: GeniusDex <geniusdex@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" - -/* ------------------------------------------------------------ - * Name: cs_appendtopic - * Author: SGR <Alex_SGR@ntlworld.com> - * Date: 31/08/2003 - * ------------------------------------------------------------ - * - * This module has no configurable options. For information on - * this module, load it and refer to /ChanServ APPENDTOPIC HELP - * - * Thanks to dengel, Rob and Certus for all there support. - * Especially Rob, who always manages to show me where I have - * not allocated any memory. Even if it takes a few weeks of - * pestering to get him to look at it. - * - * ------------------------------------------------------------ - */ - -/* ---------------------------------------------------------------------- */ -/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ -/* ---------------------------------------------------------------------- */ - -class CommandCSAppendTopic : public Command -{ - public: - CommandCSAppendTopic(Module *creator) : Command(creator, "chanserv/appendtopic", 2, 2) - { - this->SetDesc(_("Add text to a channels topic")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - const Anope::string &newtopic = params[1]; - - User *u = source.u; - Channel *c = findchan(params[0]);; - - 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 (!c->ci->HasPriv(u, CA_TOPIC)) - source.Reply(ACCESS_DENIED); - else - { - Anope::string topic; - if (!c->ci->last_topic.empty()) - { - topic = c->ci->last_topic + " " + newtopic; - c->ci->last_topic.clear(); - } - else - topic = newtopic; - - bool has_topiclock = c->ci->HasFlag(CI_TOPICLOCK); - c->ci->UnsetFlag(CI_TOPICLOCK); - c->ChangeTopic(u->nick, topic, Anope::CurTime); - if (has_topiclock) - c->ci->SetFlag(CI_TOPICLOCK); - - bool override = c->ci->HasPriv(u, CA_TOPIC); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci) << "changed topic to " << topic; - } - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: APPENDTOPIC channel text")); - source.Reply(" "); - source.Reply(("This command allows users to append text to a currently set\n" - "channel topic. When TOPICLOCK is on, the topic is updated and\n" - "the new, updated topic is locked.")); - - return true; - } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: APPENDTOPIC channel text")); - } -}; - -class CSAppendTopic : public Module -{ - CommandCSAppendTopic commandcsappendtopic; - - public: - CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), - commandcsappendtopic(this) - { - this->SetAuthor("SGR"); - - ModuleManager::RegisterService(&commandcsappendtopic); - } -}; - -MODULE_INIT(CSAppendTopic) diff --git a/modules/extra/cs_enforce.cpp b/modules/extra/cs_enforce.cpp deleted file mode 100644 index 26885c9b0..000000000 --- a/modules/extra/cs_enforce.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* cs_enforce - Add a /cs ENFORCE command to enforce various set - * options and channelmodes on a channel. - * - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Included in the Anope module pack since Anope 1.7.9 - * Anope Coder: GeniusDex <geniusdex@anope.org> - * - * Please read COPYING and README for further details. - * - * Send any bug reports to the Anope Coder, as he will be able - * to deal with it best. - */ - -#include "module.h" - -class CommandCSEnforce : public Command -{ - private: - void DoSet(Channel *c) - { - ChannelInfo *ci; - - if (!(ci = c->ci)) - return; - - if (ci->HasFlag(CI_SECUREOPS)) - this->DoSecureOps(c); - if (ci->HasFlag(CI_RESTRICTED)) - this->DoRestricted(c); - } - - void DoModes(Channel *c) - { - if (c->HasMode(CMODE_REGISTEREDONLY)) - this->DoCModeR(c); - } - - void DoSecureOps(Channel *c) - { - ChannelInfo *ci; - bool hadsecureops = false; - - if (!(ci = c->ci)) - return; - - /* Dirty hack to allow chan_set_correct_modes to work ok. - * We pretend like SECUREOPS is on so it doesn't ignore that - * part of the code. This way we can enforce SECUREOPS even - * if it's off. - */ - if (!ci->HasFlag(CI_SECUREOPS)) - { - ci->SetFlag(CI_SECUREOPS); - hadsecureops = true; - } - - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - chan_set_correct_modes(uc->user, c, 0); - } - - if (hadsecureops) - ci->UnsetFlag(CI_SECUREOPS); - } - - void DoRestricted(Channel *c) - { - ChannelInfo *ci = c->ci; - if (ci == NULL) - return; - - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) - { - UserContainer *uc = *it++; - User *user = uc->user; - - if (ci->AccessFor(user).empty()) - { - Anope::string mask; - get_idealban(ci, user, mask); - Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN); - c->SetMode(NULL, CMODE_BAN, mask); - c->Kick(NULL, user, "%s", reason.c_str()); - } - } - } - - void DoCModeR(Channel *c) - { - ChannelInfo *ci; - Anope::string mask; - - if (!(ci = c->ci)) - return; - - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) - { - UserContainer *uc = *it++; - - if (!uc->user->IsIdentified()) - { - get_idealban(ci, uc->user, mask); - Anope::string reason = translate(uc->user, CHAN_NOT_ALLOWED_TO_JOIN); - if (!c->HasMode(CMODE_REGISTEREDONLY)) - c->SetMode(NULL, CMODE_BAN, mask); - c->Kick(NULL, uc->user, "%s", reason.c_str()); - } - } - } - public: - CommandCSEnforce(Module *creator) : Command(creator, "chanserv/enforce", 1, 2) - { - this->SetDesc(_("Enforce various channel modes and set options")); - this->SetSyntax(_("\037channel\037 [\037what\037]")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - const Anope::string &what = params.size() > 1 ? params[1] : ""; - - User *u = source.u; - Channel *c = findchan(params[0]); - - 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 (!c->ci->HasPriv(u, CA_AKICK)) - source.Reply(ACCESS_DENIED); - else - { - if (what.empty() || what.equals_ci("SET")) - { - this->DoSet(c); - source.Reply(_("Enforced %s"), !what.empty() ? what.c_str() : "SET"); - } - else if (what.equals_ci("MODES")) - { - this->DoModes(c); - source.Reply(_("Enforced %s"), what.c_str()); - } - else if (what.equals_ci("SECUREOPS")) - { - this->DoSecureOps(c); - source.Reply(_("Enforced %s"), what.c_str()); - } - else if (what.equals_ci("RESTRICTED")) - { - this->DoRestricted(c); - source.Reply(_("Enforced %s"), what.c_str()); - } - else if (what.equals_ci("+R")) - { - this->DoCModeR(c); - source.Reply(_("Enforced %s"), what.c_str()); - } - else - this->OnSyntaxError(source, ""); - } - - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Enforce various channel modes and set options. The \037channel\037\n" - "option indicates what channel to enforce the modes and options\n" - "on. The \037what\037 option indicates what modes and options to\n" - "enforce, and can be any of SET, SECUREOPS, RESTRICTED, MODES,\n" - "or +R. When left out, it defaults to SET.\n" - " \n" - "If \037what\037 is SET, it will enforce SECUREOPS and RESTRICTED\n" - "on the users currently in the channel, if they are set. Give\n" - "SECUREOPS to enforce the SECUREOPS option, even if it is not\n" - "enabled. Use RESTRICTED to enfore the RESTRICTED option, also\n" - "if it's not enabled.")); - source.Reply(" "); - if (ModeManager::FindChannelModeByName(CMODE_REGISTERED)) - source.Reply(_("If \037what\037 is MODES, it will enforce channelmode +R if it is\n" - "set. If +R is specified for \037what\037, the +R channelmode will\n" - "also be enforced, but even if it is not set. If it is not set,\n" - "users will be banned to ensure they don't just rejoin.")); - else - source.Reply(_("If \037what\037 is MODES, nothing will be enforced, since it would\n" - "enforce modes that the current ircd does not support. If +R is\n" - "specified for \037what\037, an equalivant of channelmode +R on\n" - "other ircds will be enforced. All users that are in the channel\n" - "but have not identified for their nickname will be kicked and\n" - "banned from the channel.")); - - return true; - } -}; - -class CSEnforce : public Module -{ - CommandCSEnforce commandcsenforce; - - public: - CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), - commandcsenforce(this) - { - this->SetAuthor("Anope"); - - ModuleManager::RegisterService(&commandcsenforce); - } -}; - -MODULE_INIT(CSEnforce) diff --git a/modules/extra/cs_entrymsg.cpp b/modules/extra/cs_entrymsg.cpp deleted file mode 100644 index 3aa8ed862..000000000 --- a/modules/extra/cs_entrymsg.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" - -struct EntryMsg -{ - static unsigned MaxEntries; - - EntryMsg(const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime) - { - this->creator = cname; - this->message = cmessage; - this->when = ct; - } - - Anope::string creator; - Anope::string message; - time_t when; -}; -unsigned EntryMsg::MaxEntries = 0; - -class CommandEntryMessage : public Command -{ - private: - void DoList(CommandSource &source, ChannelInfo *ci) - { - std::vector<EntryMsg> messages; - if (ci->GetExtRegular("cs_entrymsg", messages)) - { - source.Reply(_("Entry message list for \2%s\2:"), ci->name.c_str()); - for (unsigned i = 0; i < messages.size(); ++i) - source.Reply(CHAN_LIST_ENTRY, i + 1, messages[i].message.c_str(), messages[i].creator.c_str(), do_strftime(messages[i].when).c_str()); - source.Reply(_("End of entry message list.")); - } - else - source.Reply(_("Entry message list for \2%s\2 is empty."), ci->name.c_str()); - } - - void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message) - { - std::vector<EntryMsg> messages; - ci->GetExtRegular("cs_entrymsg", messages); - - if (EntryMsg::MaxEntries && messages.size() >= EntryMsg::MaxEntries) - source.Reply(_("The entry message list for \2%s\2 is full."), ci->name.c_str()); - else - { - messages.push_back(EntryMsg(source.u->nick, message)); - ci->Extend("cs_entrymsg", new ExtensibleItemRegular<std::vector<EntryMsg> >(messages)); - source.Reply(_("Entry message added to \2%s\2"), ci->name.c_str()); - } - } - - void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message) - { - std::vector<EntryMsg> messages; - if (!message.is_pos_number_only()) - source.Reply(("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str()); - else if (ci->GetExtRegular("cs_entrymsg", messages)) - { - try - { - unsigned i = convertTo<unsigned>(message); - if (i > 0 && i <= messages.size()) - { - messages.erase(messages.begin() + i - 1); - if (!messages.empty()) - ci->Extend("cs_entrymsg", new ExtensibleItemRegular<std::vector<EntryMsg> >(messages)); - else - ci->Shrink("cs_entrymsg"); - source.Reply(_("Entry message \2%i\2 for \2%s\2 deleted."), i, ci->name.c_str()); - } - else - throw ConvertException(); - } - catch (const ConvertException &) - { - source.Reply(_("Entry message \2%s\2 not found on channel \2%s\2."), message.c_str(), ci->name.c_str()); - } - } - else - source.Reply(_("Entry message list for \2%s\2 is empty."), ci->name.c_str()); - } - - void DoClear(CommandSource &source, ChannelInfo *ci) - { - ci->Shrink("cs_entrymsg"); - source.Reply(_("Entry messages for \2%s\2 have been cleared."), ci->name.c_str()); - } - - public: - CommandEntryMessage(Module *creator) : Command(creator, "chanserv/entrymsg", 2, 3) - { - this->SetDesc(_("Manage the channel's entry messages")); - this->SetSyntax(_("\037channel\037 {ADD|DEL|LIST|CLEAR} [\037message\037|\037num\037]")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - User *u = source.u; - - ChannelInfo *ci = cs_findchan(params[0]); - if (ci == NULL) - { - source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); - return; - } - - if (IsFounder(u, ci) || u->HasCommand("chanserv/entrymsg")) - { - bool success = true; - if (params[1].equals_ci("LIST")) - this->DoList(source, ci); - else if (params[1].equals_ci("CLEAR")) - this->DoClear(source, ci); - else if (params.size() < 3) - { - success = false; - this->OnSyntaxError(source, ""); - } - else if (params[1].equals_ci("ADD")) - this->DoAdd(source, ci, params[2]); - else if (params[1].equals_ci("DEL")) - this->DoDel(source, ci, params[2]); - else - { - success = false; - this->OnSyntaxError(source, ""); - } - if (success) - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << params[1]; - } - else - source.Reply(ACCESS_DENIED); - - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Controls what messages will be sent to users when they join the channel.")); - return true; - } -}; - -class CSEntryMessage : public Module -{ - CommandEntryMessage commandentrymsg; - - public: - CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), commandentrymsg(this) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnJoinChannel, I_OnReload, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - ModuleManager::RegisterService(&commandentrymsg); - - this->OnReload(); - } - - void OnJoinChannel(User *u, Channel *c) - { - if (u && c && c->ci && u->server->IsSynced()) - { - std::vector<EntryMsg> messages; - - if (c->ci->GetExtRegular("cs_entrymsg", messages)) - for (unsigned i = 0; i < messages.size(); ++i) - u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), messages[i].message.c_str()); - } - } - - void OnReload() - { - ConfigReader config; - EntryMsg::MaxEntries = config.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true); - } - - EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, const std::vector<Anope::string> ¶ms) - { - if (key.find("CS_ENTRYMSG_") == 0 && params.size() > 2) - { - Anope::string creator = params[0]; - time_t t = params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime; - Anope::string message = params[2]; - for (unsigned j = 3; j < params.size(); ++j) - message += " " + params[j]; - - std::vector<EntryMsg> messages; - ci->GetExtRegular("cs_entrymsg", messages); - messages.push_back(EntryMsg(creator, message, t)); - ci->Extend("cs_entrymsg", new ExtensibleItemRegular<std::vector<EntryMsg> >(messages)); - - return EVENT_STOP; - } - - return EVENT_CONTINUE; - } - - void OnDatabaseWriteMetadata(void (*WriteMetadata)(const Anope::string &, const Anope::string &), ChannelInfo *ci) - { - std::vector<EntryMsg> messages; - if (ci->GetExtRegular("cs_entrymsg", messages)) - for (unsigned i = 0; i < messages.size(); ++i) - WriteMetadata("CS_ENTRYMSG_" + stringify(i), messages[i].creator + " " + stringify(messages[i].when) + " " + messages[i].message); - } -}; - -MODULE_INIT(CSEntryMessage) diff --git a/modules/extra/cs_set_misc.cpp b/modules/extra/cs_set_misc.cpp deleted file mode 100644 index 8f145ab88..000000000 --- a/modules/extra/cs_set_misc.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" - -class CommandCSSetMisc : public Command -{ - public: - CommandCSSetMisc(Module *creator, const Anope::string &cname = "chanserv/set/misc") : Command(creator, cname, 1, 2) - { - this->SetSyntax(_("\037channel\037 \037parameters\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - ChannelInfo *ci = cs_findchan(params[0]); - if (ci == NULL) - { - source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); - return; - } - - ci->Shrink("cs_set_misc:" + source.command.replace_all_cs(" ", "_")); - if (params.size() > 1) - { - ci->Extend("cs_set_misc:" + source.command.replace_all_cs(" ", "_"), new ExtensibleItemRegular<Anope::string>(params[1])); - source.Reply(CHAN_SETTING_CHANGED, source.command.c_str(), ci->name.c_str(), params[1].c_str()); - } - else - source.Reply(CHAN_SETTING_UNSET, source.command.c_str(), ci->name.c_str()); - } -}; - -class CommandCSSASetMisc : public CommandCSSetMisc -{ - public: - CommandCSSASetMisc(Module *creator) : CommandCSSetMisc(creator, "chanserv/saset/misc") - { - } -}; - -class CSSetMisc : public Module -{ - CommandCSSetMisc commandcssetmisc; - CommandCSSASetMisc commandcssasetmisc; - - public: - CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), - commandcssetmisc(this), commandcssasetmisc(this) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnChanInfo, I_OnDatabaseWriteMetadata, I_OnDatabaseReadMetadata }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - ModuleManager::RegisterService(&this->commandcssetmisc); - ModuleManager::RegisterService(&this->commandcssasetmisc); - } - - void OnChanInfo(CommandSource &source, ChannelInfo *ci, bool ShowHidden) - { - std::deque<Anope::string> list; - ci->GetExtList(list); - - for (unsigned i = 0; i < list.size(); ++i) - { - if (list[i].find("cs_set_misc:") != 0) - continue; - - Anope::string value; - if (ci->GetExtRegular(list[i], value)) - source.Reply(" %s: %s", list[i].substr(12).replace_all_cs("_", " ").c_str(), value.c_str()); - } - } - - void OnDatabaseWriteMetadata(void (*WriteMetadata)(const Anope::string &, const Anope::string &), ChannelInfo *ci) - { - std::deque<Anope::string> list; - ci->GetExtList(list); - - for (unsigned i = 0; i < list.size(); ++i) - { - if (list[i].find("cs_set_misc:") != 0) - continue; - - Anope::string value; - if (ci->GetExtRegular(list[i], value)) - WriteMetadata(list[i], ":" + value); - } - } - - EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, const std::vector<Anope::string> ¶ms) - { - if (key.find("cs_set_misc:") == 0) - ci->Extend(key, new ExtensibleItemRegular<Anope::string>(params[0])); - - return EVENT_CONTINUE; - } -}; - -MODULE_INIT(CSSetMisc) diff --git a/modules/extra/cs_sync.cpp b/modules/extra/cs_sync.cpp deleted file mode 100644 index 2937cc4fc..000000000 --- a/modules/extra/cs_sync.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "module.h" - -class CommandCSSync : public Command -{ - public: - CommandCSSync(Module *creator) : Command(creator, "chanserv/sync", 1, 1) - { - this->SetDesc(_("Sync users channel modes")); - this->SetSyntax(_("\037channel\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - ChannelInfo *ci = cs_findchan(params[0]); - - if (ci == NULL) - source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); - else if (ci->c == NULL) - source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); - else - { - for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - chan_set_correct_modes((*it)->user, ci->c, 1); - - source.Reply(_("All user modes on \2%s\2 have been synced."), ci->name.c_str()); - } - } - - bool OnHelp(CommandSource &source, const Anope::string ¶ms) - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Syncs all modes set on users on the channel with the modes\n" - "they should have based on their access.")); - return true; - } -}; - -class CSSync : public Module -{ - CommandCSSync commandcssync; - public: - CSSync(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), - commandcssync(this) - { - this->SetAuthor("Anope"); - - ModuleManager::RegisterService(&commandcssync); - } -}; - -MODULE_INIT(CSSync) diff --git a/modules/extra/cs_tban.cpp b/modules/extra/cs_tban.cpp deleted file mode 100644 index 404279bef..000000000 --- a/modules/extra/cs_tban.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* cs_tban.c - Bans the user for a given length of time - * - * (C) 2003-2011 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: - dynamic_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) - { - if (chan && chan->ci) - chan->RemoveMode(NULL, CMODE_BAN, mask); - } -}; - -static bool CanBanUser(CommandSource &source, Channel *c, User *u2) -{ - User *u = source.u; - ChannelInfo *ci = c->ci; - bool ok = false; - if (!ci->HasPriv(u, CA_BAN)) - source.Reply(ACCESS_DENIED); - else if (matches_list(c, u2, CMODE_EXCEPT)) - source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); - else if (u2->IsProtected()) - source.Reply(ACCESS_DENIED); - else - ok = true; - - return ok; -} - -class CommandCSTBan : public Command -{ - public: - CommandCSTBan(Module *m) : Command(m, "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) - { - Channel *c = findchan(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 (!(u2 = finduser(nick))) - source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); - else |
