]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_modenotice.cpp
Fix MySQL crash on module unload with empty query queue
[user/henk/code/inspircd.git] / src / commands / cmd_modenotice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 class CommandModeNotice : public Command
17 {
18  public:
19         CommandModeNotice(Module* parent) : Command(parent,"MODENOTICE",2,2)
20         {
21                 syntax = "<modes> <message>";
22                 flags_needed = 'o';
23         }
24
25         CmdResult Handle(const std::vector<std::string>& parameters, User *src)
26         {
27                 int mlen = parameters[0].length();
28                 for (std::vector<LocalUser*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
29                 {
30                         User* user = *i;
31                         for (int n = 0; n < mlen; n++)
32                         {
33                                 if (!user->IsModeSet(parameters[0][n]))
34                                         goto next_user;
35                         }
36                         user->Write(":%s NOTICE %s :*** From %s: %s", ServerInstance->Config->ServerName.c_str(),
37                                 user->nick.c_str(), src->nick.c_str(), parameters[1].c_str());
38 next_user:      ;
39                 }
40                 return CMD_SUCCESS;
41         }
42
43         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
44         {
45                 return ROUTE_BROADCAST;
46         }
47 };
48
49 COMMAND_INIT(CommandModeNotice)