]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_modenotice.cpp
Fix the cloaking module on C++98 compilers.
[user/henk/code/inspircd.git] / src / modules / m_modenotice.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2013-2014 Attila Molnar <attilamolnar@hush.com>
6  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8  *
9  * This file is part of InspIRCd.  InspIRCd is free software: you can
10  * redistribute it and/or modify it under the terms of the GNU General Public
11  * License as published by the Free Software Foundation, version 2.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22
23 #include "inspircd.h"
24
25 class CommandModeNotice : public Command
26 {
27  public:
28         CommandModeNotice(Module* parent) : Command(parent,"MODENOTICE",2,2)
29         {
30                 syntax = "<modeletters> :<message>";
31                 flags_needed = 'o';
32         }
33
34         CmdResult Handle(User* src, const Params& parameters) CXX11_OVERRIDE
35         {
36                 std::string msg = "*** From " + src->nick + ": " + parameters[1];
37                 int mlen = parameters[0].length();
38                 const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
39                 for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
40                 {
41                         User* user = *i;
42                         for (int n = 0; n < mlen; n++)
43                         {
44                                 if (!user->IsModeSet(parameters[0][n]))
45                                         goto next_user;
46                         }
47                         user->WriteNotice(msg);
48 next_user:      ;
49                 }
50                 return CMD_SUCCESS;
51         }
52
53         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
54         {
55                 return ROUTE_OPT_BCAST;
56         }
57 };
58
59 class ModuleModeNotice : public Module
60 {
61         CommandModeNotice cmd;
62
63  public:
64         ModuleModeNotice()
65                 : cmd(this)
66         {
67         }
68
69         Version GetVersion() CXX11_OVERRIDE
70         {
71                 return Version("Adds the /MODENOTICE command which sends a message to all users with the specified user modes set.", VF_VENDOR);
72         }
73 };
74
75 MODULE_INIT(ModuleModeNotice)