anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
cs_drop.cpp (2638B)
1 /* ChanServ core functions 2 * 3 * (C) 2003-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * Please read COPYING and README for further details. 7 * 8 * Based on the original code of Epona by Lara. 9 * Based on the original code of Services by Andy Church. 10 */ 11 12 #include "module.h" 13 14 class CommandCSDrop : public Command 15 { 16 public: 17 CommandCSDrop(Module *creator) : Command(creator, "chanserv/drop", 1, 2) 18 { 19 this->SetDesc(_("Cancel the registration of a channel")); 20 this->SetSyntax(_("\037channel\037 \037channel\037")); 21 } 22 23 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 24 { 25 const Anope::string &chan = params[0]; 26 27 if (Anope::ReadOnly && !source.HasPriv("chanserv/administration")) 28 { 29 source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE? 30 return; 31 } 32 33 ChannelInfo *ci = ChannelInfo::Find(chan); 34 if (ci == NULL) 35 { 36 source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); 37 return; 38 } 39 40 if (params.size() < 2 || !chan.equals_ci(params[1])) 41 { 42 source.Reply(_("You must enter the channel name twice as a confirmation that you wish to drop \002%s\002."), chan.c_str()); 43 return; 44 } 45 46 if ((ci->HasExt("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) 47 { 48 source.Reply(ACCESS_DENIED); 49 return; 50 } 51 52 EventReturn MOD_RESULT; 53 FOREACH_RESULT(OnChanDrop, MOD_RESULT, (source, ci)); 54 if (MOD_RESULT == EVENT_STOP) 55 return; 56 57 bool override = (ci->HasExt("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); 58 Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; 59 60 Reference<Channel> c = ci->c; 61 delete ci; 62 63 source.Reply(_("Channel \002%s\002 has been dropped."), chan.c_str()); 64 65 if (c) 66 c->CheckModes(); 67 } 68 69 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 70 { 71 this->SendSyntax(source); 72 source.Reply(" "); 73 if (source.IsServicesOper()) 74 source.Reply(_("Unregisters the specified channel. Only \002Services Operators\002\n" 75 "can drop a channel of which they are not the founder of.")); 76 else 77 source.Reply(_("Unregisters the named channel. Can only be used by\n" 78 "the \002channel founder\002.")); 79 80 return true; 81 } 82 }; 83 84 class CSDrop : public Module 85 { 86 CommandCSDrop commandcsdrop; 87 88 public: 89 CSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsdrop(this) 90 { 91 92 } 93 }; 94 95 MODULE_INIT(CSDrop)