anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
os_noop.cpp (2920B)
1 /* OperServ 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 CommandOSNOOP : public Command 15 { 16 public: 17 CommandOSNOOP(Module *creator) : Command(creator, "operserv/noop", 2, 2) 18 { 19 this->SetDesc(_("Remove all operators from a server remotely")); 20 this->SetSyntax(_("SET \037server\037")); 21 this->SetSyntax(_("REVOKE \037server\037")); 22 } 23 24 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 25 { 26 const Anope::string &cmd = params[0]; 27 const Anope::string &server = params[1]; 28 29 Server *s = Server::Find(server, true); 30 if (s == NULL) 31 source.Reply(_("Server %s does not exist."), server.c_str()); 32 else if (s == Me || s->IsJuped()) 33 source.Reply(_("You can not NOOP Services.")); 34 else if (cmd.equals_ci("SET")) 35 { 36 /* Remove the O:lines */ 37 IRCD->SendSVSNOOP(s, true); 38 s->Extend<Anope::string>("noop", source.GetNick()); 39 40 Log(LOG_ADMIN, source, this) << "SET on " << s->GetName(); 41 source.Reply(_("All operators from \002%s\002 have been removed."), s->GetName().c_str()); 42 43 Anope::string reason = "NOOP command used by " + source.GetNick(); 44 /* Kill all the IRCops of the server */ 45 for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) 46 { 47 User *u2 = it->second; 48 49 if (u2->server == s && u2->HasMode("OPER")) 50 u2->Kill(*source.service, reason); 51 } 52 } 53 else if (cmd.equals_ci("REVOKE")) 54 { 55 s->Shrink<Anope::string>("noop"); 56 IRCD->SendSVSNOOP(s, false); 57 Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName(); 58 source.Reply(_("All O:lines of \002%s\002 have been reset."), s->GetName().c_str()); 59 } 60 else 61 this->OnSyntaxError(source, ""); 62 } 63 64 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 65 { 66 this->SendSyntax(source); 67 source.Reply(" "); 68 source.Reply(_("\002SET\002 kills all operators from the given\n" 69 "\002server\002 and prevents operators from opering\n" 70 "up on the given server. \002REVOKE\002 removes this\n" 71 "restriction.")); 72 return true; 73 } 74 }; 75 76 class OSNOOP : public Module 77 { 78 CommandOSNOOP commandosnoop; 79 PrimitiveExtensibleItem<Anope::string> noop; 80 81 public: 82 OSNOOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), 83 commandosnoop(this), noop(this, "noop") 84 { 85 86 } 87 88 void OnUserModeSet(const MessageSource &, User *u, const Anope::string &mname) anope_override 89 { 90 Anope::string *setter; 91 if (mname == "OPER" && (setter = noop.Get(u->server))) 92 { 93 Anope::string reason = "NOOP command used by " + *setter; 94 BotInfo *OperServ = Config->GetClient("OperServ"); 95 u->Kill(OperServ, reason); 96 } 97 } 98 }; 99 100 MODULE_INIT(OSNOOP)