diff options
Diffstat (limited to 'modules/commands/cs_set_persist.cpp')
-rw-r--r-- | modules/commands/cs_set_persist.cpp | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/modules/commands/cs_set_persist.cpp b/modules/commands/cs_set_persist.cpp deleted file mode 100644 index 03e5d3a84..000000000 --- a/modules/commands/cs_set_persist.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2012 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 CommandCSSetPersist : public Command -{ - public: - CommandCSSetPersist(Module *creator, const Anope::string &cname = "chanserv/set/persist") : Command(creator, cname, 2, 2) - { - this->SetDesc(_("Set the channel as permanent")); - this->SetSyntax(_("\037channel\037 {ON | OFF}")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - ChannelInfo *ci = ChannelInfo::Find(params[0]); - if (ci == NULL) - { - source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); - return; - } - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); - if (MOD_RESULT == EVENT_STOP) - return; - - if (MOD_RESULT != EVENT_ALLOW && source.permission.empty() && !source.AccessFor(ci).HasPriv("SET")) - { - source.Reply(ACCESS_DENIED); - return; - } - - ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PERM); - - if (params[1].equals_ci("ON")) - { - if (!ci->HasFlag(CI_PERSIST)) - { - ci->SetFlag(CI_PERSIST); - if (ci->c) - ci->c->SetFlag(CH_PERSIST); - - /* Channel doesn't exist, create it */ - if (!ci->c) - { - Channel *c = new Channel(ci->name); - if (ci->bi) - ci->bi->Join(c); - } - - /* No botserv bot, no channel mode, give them ChanServ. - * Yes, this works fine with no Config->BotServ. - */ - if (!ci->bi && !cm) - { - if (!ChanServ) - { - source.Reply(_("ChanServ is required to enable persist on this network.")); - return; - } - ChanServ->Assign(NULL, ci); - if (!ci->c->FindUser(ChanServ)) - ChanServ->Join(ci->c); - } - - /* Set the perm mode */ - if (cm) - { - if (ci->c && !ci->c->HasMode(CMODE_PERM)) - ci->c->SetMode(NULL, cm); - /* Add it to the channels mlock */ - ci->SetMLock(cm, true); - } - } - - source.Reply(_("Channel \002%s\002 is now persistent."), ci->name.c_str()); - } - else if (params[1].equals_ci("OFF")) - { - if (ci->HasFlag(CI_PERSIST)) - { - ci->UnsetFlag(CI_PERSIST); - if (ci->c) - ci->c->UnsetFlag(CH_PERSIST); - - /* Unset perm mode */ - if (cm) - { - if (ci->c && ci->c->HasMode(CMODE_PERM)) - ci->c->RemoveMode(NULL, cm); - /* Remove from mlock */ - ci->RemoveMLock(cm, true); - } - - /* No channel mode, no BotServ, but using ChanServ as the botserv bot - * which was assigned when persist was set on - */ - if (!cm && Config->BotServ.empty() && ci->bi) - { - if (!ChanServ) - { - source.Reply(_("ChanServ is required to enable persist on this network.")); - return; - } - /* Unassign bot */ - ChanServ->UnAssign(NULL, ci); - } - } - - source.Reply(_("Channel \002%s\002 is no longer persistent."), ci->name.c_str()); - } - else - this->OnSyntaxError(source, "PERSIST"); - - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &) anope_override - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Enables or disables the persistent channel setting.\n" - "When persistent is set, the service bot will remain\n" - "in the channel when it has emptied of users.\n" - " \n" - "If your IRCd does not have a permanent (persistent) channel\n" - "mode you must have a service bot in your channel to\n" - "set persist on, and it can not be unassigned while persist\n" - "is on.\n" - " \n" - "If this network does not have BotServ enabled and does\n" - "not have a permanent channel mode, ChanServ will\n" - "join your channel when you set persist on (and leave when\n" - "it has been set off).\n" - " \n" - "If your IRCd has a permanent (persistent) channel mode\n" - "and it is set or unset (for any reason, including MODE LOCK),\n" - "persist is automatically set and unset for the channel aswell.\n" - "Additionally, services will set or unset this mode when you\n" - "set persist on or off.")); - return true; - } -}; - -class CSSetPersist : public Module -{ - CommandCSSetPersist commandcssetpeace; - - public: - CSSetPersist(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - commandcssetpeace(this) - { - this->SetAuthor("Anope"); - - ModuleManager::Attach(I_OnDelChan, this); - } - - void OnDelChan(ChannelInfo *ci) anope_override - { - if (ci->c && ci->HasFlag(CI_PERSIST)) - ci->c->RemoveMode(NULL, CMODE_PERM, "", false); - } -}; - -MODULE_INIT(CSSetPersist) |