]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_samode.cpp
Updates, should be able to safely unload client modules with queries in progress...
[user/henk/code/inspircd.git] / src / modules / m_samode.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 /*
20  * SAMODE module for InspIRCd
21  *  Co authored by Brain and w00t
22  *
23  *  Syntax: /SAMODE <#chan/nick> +/-<modes> [parameters for modes]
24  * 
25  */
26
27 /* $ModDesc: Povides more advanced UnrealIRCd SAMODE command */
28
29 /*
30  * ToDo:
31  *   Err... not a lot really.
32  */ 
33
34 #include <stdio.h>
35 #include "users.h"
36 #include "channels.h"
37 #include "modules.h"
38
39 static Server *Srv;
40          
41 class cmd_samode : public command_t
42 {
43  public:
44         cmd_samode () : command_t("SAMODE", 'o', 2)
45         {
46                 this->source = "m_samode.so";
47         }
48
49         void Handle (const char** parameters, int pcnt, userrec *user)
50         {
51                 /*
52                  * Handles an SAMODE request. Notifies all +s users.
53                  */
54                 std::string result;
55                 Srv->Log(DEBUG,"SAMODE: Being handled");
56                 Srv->SendMode(parameters,pcnt,user);
57                 Srv->Log(DEBUG,"SAMODE: Modechange handled");
58                 result = std::string(user->nick);
59                 result.append(" used SAMODE");
60                 for (int n = 0; n < pcnt; n++)
61                 {
62                         result.append(" ");
63                         result.append(parameters[n]);
64                 }
65                 Srv->SendOpers(result);
66         }
67 };
68
69 class ModuleSaMode : public Module
70 {
71         cmd_samode*     mycommand;
72  public:
73         ModuleSaMode(Server* Me)
74                 : Module::Module(Me)
75         {
76                 Srv = Me;
77                 mycommand = new cmd_samode();
78                 Srv->AddCommand(mycommand);
79         }
80         
81         virtual ~ModuleSaMode()
82         {
83         }
84         
85         virtual Version GetVersion()
86         {
87                 return Version(1,0,2,2,VF_VENDOR);
88         }
89 };
90
91
92 class ModuleSaModeFactory : public ModuleFactory
93 {
94  public:
95         ModuleSaModeFactory()
96         {
97         }
98         
99         ~ModuleSaModeFactory()
100         {
101         }
102         
103         virtual Module * CreateModule(Server* Me)
104         {
105                 return new ModuleSaMode(Me);
106         }
107         
108 };
109
110
111 extern "C" void * init_module( void )
112 {
113         return new ModuleSaModeFactory;
114 }