anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

os_jupe.cpp (2577B)

      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 CommandOSJupe : public Command
     15 {
     16  public:
     17 	CommandOSJupe(Module *creator) : Command(creator, "operserv/jupe", 1, 2)
     18 	{
     19 		this->SetDesc(_("\"Jupiter\" a server"));
     20 		this->SetSyntax(_("\037server\037 [\037reason\037]"));
     21 	}
     22 
     23 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     24 	{
     25 		const Anope::string &jserver = params[0];
     26 		const Anope::string &reason = params.size() > 1 ? params[1] : "";
     27 		Server *server = Server::Find(jserver, true);
     28 
     29 		if (!IRCD->IsHostValid(jserver) || jserver.find('.') == Anope::string::npos)
     30 			source.Reply(_("Please use a valid server name when juping."));
     31 		else if (server == Me || server == Servers::GetUplink())
     32 			source.Reply(_("You can not jupe your Services' pseudoserver or your uplink server."));
     33 		else if (server && server->IsJuped())
     34 			source.Reply(_("You can not jupe an already juped server."));
     35 		else
     36 		{
     37 			Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : "");
     38 			/* Generate the new sid before quitting the old server, so they can't collide */
     39 			Anope::string sid = IRCD->SID_Retrieve();
     40 			if (server)
     41 			{
     42 				IRCD->SendSquit(server, rbuf);
     43 				server->Delete(rbuf);
     44 			}
     45 			Server *juped_server = new Server(Me, jserver, 1, rbuf, sid, true);
     46 			IRCD->SendServer(juped_server);
     47 
     48 			Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")";
     49 		}
     50 	}
     51 
     52 	bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
     53 	{
     54 		this->SendSyntax(source);
     55 		source.Reply(" ");
     56 		source.Reply(_("Tells Services to jupiter a server -- that is, to create\n"
     57 				"a fake \"server\" connected to Services which prevents\n"
     58 				"the real server of that name from connecting.  The jupe\n"
     59 				"may be removed using a standard \002SQUIT\002. If a reason is\n"
     60 				"given, it is placed in the server information field;\n"
     61 				"otherwise, the server information field will contain the\n"
     62 				"text \"Juped by <nick>\", showing the nickname of the\n"
     63 				"person who jupitered the server."));
     64 		return true;
     65 	}
     66 };
     67 
     68 class OSJupe : public Module
     69 {
     70 	CommandOSJupe commandosjupe;
     71 
     72  public:
     73 	OSJupe(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
     74 		commandosjupe(this)
     75 	{
     76 
     77 	}
     78 };
     79 
     80 MODULE_INIT(OSJupe)