anope

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

ms_sendall.cpp (1702B)

      1 /* MemoServ 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 namespace
     15 {
     16 	ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
     17 }
     18 
     19 class CommandMSSendAll : public Command
     20 {
     21  public:
     22 	CommandMSSendAll(Module *creator) : Command(creator, "memoserv/sendall", 1, 1)
     23 	{
     24 		this->SetDesc(_("Send a memo to all registered users"));
     25 		this->SetSyntax(_("\037memo-text\037"));
     26 	}
     27 
     28 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     29 	{
     30 		if (!memoserv)
     31 			return;
     32 
     33 		const Anope::string &text = params[0];
     34 
     35 		Log(LOG_ADMIN, source, this) << "to send " << text;
     36 
     37 		for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
     38 		{
     39 			const NickCore *nc = it->second;
     40 
     41 			if (nc != source.nc)
     42 				memoserv->Send(source.GetNick(), nc->display, text);
     43 		}
     44 
     45 		source.Reply(_("A massmemo has been sent to all registered users."));
     46 	}
     47 
     48 	bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
     49 	{
     50 		this->SendSyntax(source);
     51 		source.Reply(" ");
     52 		source.Reply(_("Sends all registered users a memo containing \037memo-text\037."));
     53 		return true;
     54 	}
     55 };
     56 
     57 class MSSendAll : public Module
     58 {
     59 	CommandMSSendAll commandmssendall;
     60 
     61  public:
     62 	MSSendAll(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
     63 		commandmssendall(this)
     64 	{
     65 		if (!memoserv)
     66 			throw ModuleException("No MemoServ!");
     67 	}
     68 };
     69 
     70 MODULE_INIT(MSSendAll)