]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_modenotice.cpp
Move MODENOTICE command to a command module
[user/henk/code/inspircd.git] / src / commands / cmd_modenotice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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) { syntax = "<modes> <message>"; }
20
21         CmdResult Handle(const std::vector<std::string>& parameters, User *src)
22         {
23                 int mlen = parameters[0].length();
24                 for (std::vector<LocalUser*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
25                 {
26                         User* user = *i;
27                         for (int n = 0; n < mlen; n++)
28                         {
29                                 if (!user->IsModeSet(parameters[0][n]))
30                                         goto next_user;
31                         }
32                         user->Write(":%s NOTICE %s :*** From %s: %s", ServerInstance->Config->ServerName.c_str(),
33                                 user->nick.c_str(), src->nick.c_str(), parameters[1].c_str());
34 next_user:      ;
35                 }
36                 return CMD_SUCCESS;
37         }
38
39         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
40         {
41                 return ROUTE_BROADCAST;
42         }
43 };
44
45 COMMAND_INIT(CommandModeNotice)