ms_staff.cpp

Go to the documentation of this file.
00001 /* MemoServ core functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church.
00010  */
00011 
00012 /*************************************************************************/
00013 
00014 #include "module.h"
00015 #include "memoserv.h"
00016 
00017 static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ");
00018 
00019 class CommandMSStaff : public Command
00020 {
00021  public:
00022         CommandMSStaff(Module *creator) : Command(creator, "memoserv/staff", 1, 1)
00023         {
00024                 this->SetDesc(_("Send a memo to all opers/admins"));
00025                 this->SetSyntax(_("\037memo-text\037"));
00026         }
00027 
00028         void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
00029         {
00030                 if (!MemoServService)
00031                         return;
00032 
00033                 const Anope::string &text = params[0];
00034 
00035                 if (Anope::ReadOnly)
00036                 {
00037                         source.Reply(MEMO_SEND_DISABLED);
00038                         return;
00039                 }
00040 
00041                 for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
00042                 {
00043                         const NickCore *nc = it->second;
00044 
00045                         if (source.nc != nc && nc->IsServicesOper())
00046                                 MemoServService->Send(source.GetNick(), nc->display, text, true);
00047                 }
00048 
00049                 return;
00050         }
00051 
00052         bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00053         {
00054                 this->SendSyntax(source);
00055                 source.Reply(" ");
00056                 source.Reply(_("Sends all services staff a memo containing \037memo-text\037."));
00057 
00058                 return true;
00059         }
00060 };
00061 
00062 class MSStaff : public Module
00063 {
00064         CommandMSStaff commandmsstaff;
00065 
00066  public:
00067         MSStaff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00068                 commandmsstaff(this)
00069         {
00070                 this->SetAuthor("Anope");
00071 
00072                 if (!MemoServService)
00073                         throw ModuleException("No MemoServ!");
00074         }
00075 };
00076 
00077 MODULE_INIT(MSStaff)