]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globops.cpp
75ec36929ccfae750f64bd00d17373a638f1ce10
[user/henk/code/inspircd.git] / src / modules / m_globops.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2013, 2018-2020 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
6  *   Copyright (C) 2012 Attila Molnar <attilamolnar@hush.com>
7  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8  *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9  *   Copyright (C) 2007-2008 Dennis Friis <peavey@inspircd.org>
10  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
11  *   Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
12  *
13  * This file is part of InspIRCd.  InspIRCd is free software: you can
14  * redistribute it and/or modify it under the terms of the GNU General Public
15  * License as published by the Free Software Foundation, version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
20  * details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24  */
25
26
27 // Globops and snomask +g module by C.J.Edwards
28
29 #include "inspircd.h"
30
31 /** Handle /GLOBOPS
32  */
33 class CommandGlobops : public Command
34 {
35  public:
36         CommandGlobops(Module* Creator) : Command(Creator,"GLOBOPS", 1,1)
37         {
38                 flags_needed = 'o';
39                 syntax = ":<message>";
40         }
41
42         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
43         {
44                 if (parameters[0].empty())
45                 {
46                         user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send");
47                         return CMD_FAILURE;
48                 }
49
50                 ServerInstance->SNO->WriteGlobalSno('g', "From " + user->nick + ": " + parameters[0]);
51                 return CMD_SUCCESS;
52         }
53 };
54
55 class ModuleGlobops : public Module
56 {
57         CommandGlobops cmd;
58  public:
59         ModuleGlobops() : cmd(this) {}
60
61         void init() CXX11_OVERRIDE
62         {
63                 ServerInstance->SNO->EnableSnomask('g',"GLOBOPS");
64         }
65
66         Version GetVersion() CXX11_OVERRIDE
67         {
68                 return Version("Adds the /GLOBOPS command which allows server operators to send messages to all server operators with the g (globops) snomask.", VF_VENDOR);
69         }
70 };
71
72 MODULE_INIT(ModuleGlobops)