Anope IRC Services  Version 2.0
ms_staff.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 CommandMSStaff : public Command
20 {
21  public:
22  CommandMSStaff(Module *creator) : Command(creator, "memoserv/staff", 1, 1)
23  {
24  this->SetDesc(_("Send a memo to all opers/admins"));
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  for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
36  {
37  const NickCore *nc = it->second;
38 
39  if (source.nc != nc && nc->IsServicesOper())
40  memoserv->Send(source.GetNick(), nc->display, text, true);
41  }
42  }
43 
44  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
45  {
46  this->SendSyntax(source);
47  source.Reply(" ");
48  source.Reply(_("Sends all services staff a memo containing \037memo-text\037."));
49 
50  return true;
51  }
52 };
53 
54 class MSStaff : public Module
55 {
57 
58  public:
59  MSStaff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
60  commandmsstaff(this)
61  {
62  if (!memoserv)
63  throw ModuleException("No MemoServ!");
64  }
65 };
66 
CoreExport Serialize::Checker< nickcore_map > NickCoreList
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: ms_staff.cpp:44
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
CommandMSStaff(Module *creator)
Definition: ms_staff.cpp:22
CommandMSStaff commandmsstaff
Definition: ms_staff.cpp:56
Anope::string display
Definition: account.h:113
static ServiceReference< MemoServService > memoserv("MemoServService","MemoServ")
#define anope_override
Definition: services.h:56
#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
MSStaff(const Anope::string &modname, const Anope::string &creator)
Definition: ms_staff.cpp:59
virtual bool IsServicesOper() const
Definition: nickcore.cpp:173
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: ms_staff.cpp:28
#define _(x)
Definition: services.h:50