]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_samode.cpp
nickflood: Allow changes to UID
[user/henk/code/inspircd.git] / src / modules / m_samode.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /* $ModDesc: Provides more advanced UnrealIRCd SAMODE command */
15
16 #include "inspircd.h"
17
18 /** Handle /SAMODE
19  */
20 class cmd_samode : public command_t
21 {
22  public:
23         cmd_samode (InspIRCd* Instance) : command_t(Instance,"SAMODE", 'o', 2)
24         {
25                 this->source = "m_samode.so";
26                 syntax = "<target> <modes> {<mode-parameters>}";
27         }
28
29         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
30         {
31                 /*
32                  * Handles an SAMODE request. Notifies all +s users.
33                  */
34
35                 userrec* n = new userrec(ServerInstance);
36                 n->SetFd(FD_MAGIC_NUMBER);
37                 ServerInstance->SendMode(parameters,pcnt,n);
38                 delete n;
39
40                 if (ServerInstance->Modes->GetLastParse().length())
41                 {
42                         ServerInstance->WriteOpers("*** " + std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse());
43
44                         std::deque<std::string> n;
45                         irc::spacesepstream spaced(ServerInstance->Modes->GetLastParse());
46                         std::string one = "*";
47                         while (spaced.GetToken(one))
48                                 n.push_back(one);
49
50                         Event rmode((char *)&n, NULL, "send_mode");
51                         rmode.Send(ServerInstance);
52
53                         n.clear();
54                         n.push_back(std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse());
55                         Event rmode2((char *)&n, NULL, "send_opers");
56                         rmode2.Send(ServerInstance);
57
58                         /* XXX: Yes, this is right. We dont want to propogate the
59                          * actual SAMODE command, just the MODE command generated
60                          * by the send_mode
61                          */
62                         return CMD_LOCALONLY;
63                 }
64                 else
65                 {
66                         user->WriteServ("NOTICE %s :*** Invalid SAMODE sequence.", user->nick);
67                 }
68
69                 return CMD_FAILURE;
70         }
71 };
72
73 class ModuleSaMode : public Module
74 {
75         cmd_samode*     mycommand;
76  public:
77         ModuleSaMode(InspIRCd* Me)
78                 : Module(Me)
79         {
80                 
81                 mycommand = new cmd_samode(ServerInstance);
82                 ServerInstance->AddCommand(mycommand);
83         }
84         
85         virtual ~ModuleSaMode()
86         {
87         }
88         
89         virtual Version GetVersion()
90         {
91                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
92         }
93 };
94
95 MODULE_INIT(ModuleSaMode)