anope

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

gl_global.cpp (1607B)

      1 /* Global 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 CommandGLGlobal : public Command
     15 {
     16 	ServiceReference<GlobalService> GService;
     17 
     18  public:
     19 	CommandGLGlobal(Module *creator) : Command(creator, "global/global", 1, 1), GService("GlobalService", "Global")
     20 	{
     21 		this->SetDesc(_("Send a message to all users"));
     22 		this->SetSyntax(_("\037message\037"));
     23 	}
     24 
     25 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     26 	{
     27 		const Anope::string &msg = params[0];
     28 
     29 		if (!GService)
     30 			source.Reply("No global reference, is global loaded?");
     31 		else
     32 		{
     33 			Log(LOG_ADMIN, source, this);
     34 			GService->SendGlobal(NULL, source.GetNick(), msg);
     35 		}
     36 	}
     37 
     38 	bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
     39 	{
     40 		Reference<BotInfo> sender;
     41 		if (GService)
     42 			sender = GService->GetDefaultSender();
     43 		if (!sender)
     44 			sender = source.service;
     45 
     46 		this->SendSyntax(source);
     47 		source.Reply(" ");
     48 		source.Reply(_("Allows Administrators to send messages to all users on the\n"
     49 				"network. The message will be sent from the nick \002%s\002."), sender->nick.c_str());
     50 		return true;
     51 	}
     52 };
     53 
     54 class GLGlobal : public Module
     55 {
     56 	CommandGLGlobal commandglglobal;
     57 
     58  public:
     59 	GLGlobal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
     60 		commandglglobal(this)
     61 	{
     62 
     63 	}
     64 };
     65 
     66 MODULE_INIT(GLGlobal)