]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
346132eaa3c9c6c405145e3566dc359ee77a126b
[user/henk/code/inspircd.git] / src / modules / m_devoice.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  * DEVOICE module for InspIRCd
21  *  Syntax: /DEVOICE <#chan>
22  */
23
24 /* $ModDesc: Provides voiced users with the ability to devoice themselves. */
25
26 #include <stdio.h>
27 #include "users.h"
28 #include "channels.h"
29 #include "helperfuncs.h"
30 #include "modules.h"
31
32 static Server *Srv;
33          
34 class cmd_devoice : public command_t
35 {
36  public:
37         cmd_devoice () : command_t("DEVOICE", 0, 1)
38         {
39                 this->source = "m_devoice.so";
40                 syntax = "<channel>";
41         }
42
43         void Handle (const char** parameters, int pcnt, userrec *user)
44         {
45                 /*
46                  * NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
47                  * invalid or plain confusing mode changes, code some checking!
48                  *
49                  * - I'm not aware what checking I need, so for now... be supreme evil.
50                  */
51                 const char* modes[3];
52                 modes[0] = parameters[0];
53                 modes[1] = "-v";
54                 modes[2] = user->nick;
55
56                 Srv->SendMode(modes,3,user);
57         }
58 };
59
60 class ModuleDeVoice : public Module
61 {
62         cmd_devoice *mycommand;
63  public:
64         ModuleDeVoice(Server* Me) : Module::Module(Me)
65         {
66                 log(DEBUG,"ModuleDeVoice constructor");
67                 Srv = Me;
68                 mycommand = new cmd_devoice();
69                 Srv->AddCommand(mycommand);
70         }
71         
72         virtual ~ModuleDeVoice()
73         {
74         }
75         
76         virtual Version GetVersion()
77         {
78                 return Version(1, 0, 0, 0, VF_VENDOR);
79         }
80 };
81
82
83 class ModuleDeVoiceFactory : public ModuleFactory
84 {
85  public:
86         ModuleDeVoiceFactory()
87         {
88         }
89         
90         ~ModuleDeVoiceFactory()
91         {
92         }
93         
94         virtual Module * CreateModule(Server* Me)
95         {
96                 log(DEBUG,"ModuleDevoiceFactory::CreateModule()");
97                 return new ModuleDeVoice(Me);
98         }
99         
100 };
101
102
103 extern "C" void * init_module( void )
104 {
105         return new ModuleDeVoiceFactory;
106 }