]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_wallops.cpp
Various text improvements: consistency, syntax, help and doc updates/fixes.
[user/henk/code/inspircd.git] / src / coremods / core_wallops.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #include "inspircd.h"
22
23 /** Handle /WALLOPS.
24  */
25 class CommandWallops : public Command
26 {
27         SimpleUserModeHandler wallopsmode;
28         ClientProtocol::EventProvider protoevprov;
29
30  public:
31         /** Constructor for wallops.
32          */
33         CommandWallops(Module* parent)
34                 : Command(parent, "WALLOPS", 1, 1)
35                 , wallopsmode(parent, "wallops", 'w')
36                 , protoevprov(parent, name)
37         {
38                 flags_needed = 'o';
39                 syntax = ":<message>";
40         }
41
42         /** Handle command.
43          * @param parameters The parameters to the command
44          * @param user The user issuing the command
45          * @return A value from CmdResult to indicate command success or failure.
46          */
47         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
48
49         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
50         {
51                 return ROUTE_BROADCAST;
52         }
53 };
54
55 CmdResult CommandWallops::Handle(User* user, const Params& parameters)
56 {
57         ClientProtocol::Message msg("WALLOPS", user);
58         msg.PushParamRef(parameters[0]);
59         ClientProtocol::Event wallopsevent(protoevprov, msg);
60
61         const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
62         for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
63         {
64                 LocalUser* curr = *i;
65                 if (curr->IsModeSet(wallopsmode))
66                         curr->Send(wallopsevent);
67         }
68
69         return CMD_SUCCESS;
70 }
71
72 class CoreModWallops : public Module
73 {
74  private:
75         CommandWallops cmd;
76
77  public:
78         CoreModWallops()
79                 : cmd(this)
80         {
81         }
82
83         Version GetVersion() CXX11_OVERRIDE
84         {
85                 return Version("Provides the WALLOPS command", VF_CORE | VF_VENDOR);
86         }
87 };
88
89 MODULE_INIT(CoreModWallops)