2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013-2014, 2018 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
8 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 class CommandWallops : public Command
32 SimpleUserModeHandler wallopsmode;
33 ClientProtocol::EventProvider protoevprov;
36 /** Constructor for wallops.
38 CommandWallops(Module* parent)
39 : Command(parent, "WALLOPS", 1, 1)
40 , wallopsmode(parent, "wallops", 'w')
41 , protoevprov(parent, name)
44 syntax = ":<message>";
48 * @param parameters The parameters to the command
49 * @param user The user issuing the command
50 * @return A value from CmdResult to indicate command success or failure.
52 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
54 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
56 return ROUTE_BROADCAST;
60 CmdResult CommandWallops::Handle(User* user, const Params& parameters)
62 if (parameters[0].empty())
64 user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send");
68 ClientProtocol::Message msg("WALLOPS", user);
69 msg.PushParamRef(parameters[0]);
70 ClientProtocol::Event wallopsevent(protoevprov, msg);
72 const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
73 for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
76 if (curr->IsModeSet(wallopsmode))
77 curr->Send(wallopsevent);
83 class CoreModWallops : public Module
94 Version GetVersion() CXX11_OVERRIDE
96 return Version("Provides the WALLOPS command", VF_CORE | VF_VENDOR);
100 MODULE_INIT(CoreModWallops)