Anope IRC Services  Version 2.0
ms_sendall.cpp
Go to the documentation of this file.
1 /* MemoServ core functions
2  *
3  * (C) 2003-2014 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 {
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 
CoreExport Serialize::Checker< nickcore_map > NickCoreList
CommandMSSendAll commandmssendall
Definition: ms_sendall.cpp:59
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: ms_sendall.cpp:48
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
CommandMSSendAll(Module *creator)
Definition: ms_sendall.cpp:22
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: ms_sendall.cpp:28
Anope::string display
Definition: account.h:113
static ServiceReference< MemoServService > memoserv("MemoServService","MemoServ")
#define anope_override
Definition: services.h:56
MSSendAll(const Anope::string &modname, const Anope::string &creator)
Definition: ms_sendall.cpp:62
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
void SendSyntax(CommandSource &)
Definition: command.cpp:145
Definition: logger.h:53
#define _(x)
Definition: services.h:50