]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
70d510b9ae493a3a17436cbf912029e9abde0176
[user/henk/code/inspircd.git] / src / modules / m_devoice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 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 "modules.h"
30
31 Server *Srv;
32          
33 class cmd_devoice : public command_t
34 {
35  public:
36         cmd_devoice () : command_t("DEVOICE", 'o', 2)
37         {
38                 this->source = "m_devoice.so";
39         }
40
41         void Handle (char **parameters, int pcnt, userrec *user)
42         {
43                 /*
44                  * NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
45                  * invalid or plain confusing mode changes, code some checking!
46                  *
47                  * - I'm not aware what checking I need, so for now... be supreme evil.
48                  */
49                 char* modes[3];
50                 modes[0] = parameters[0];
51                 modes[1] = "-v";
52                 modes[2] = user->nick;
53
54                 Srv->SendMode(modes,3,user);
55         }
56 };
57
58 class ModuleDeVoice : public Module
59 {
60         cmd_devoice *mycommand;
61  public:
62         ModuleDeVoice(Server* Me) : Module::Module(Me)
63         {
64                 Srv = Me;
65                 mycommand = new cmd_devoice();
66                 Srv->AddCommand(mycommand);
67         }
68         
69         virtual ~ModuleDeVoice()
70         {
71         }
72         
73         virtual Version GetVersion()
74         {
75                 return Version(1, 0, 0, 0, VF_VENDOR);
76         }
77 };
78
79
80 class ModuleDeVoiceFactory : public ModuleFactory
81 {
82  public:
83         ModuleDeVoiceFactory()
84         {
85         }
86         
87         ~ModuleDeVoiceFactory()
88         {
89         }
90         
91         virtual Module * CreateModule(Server* Me)
92         {
93                 return new ModuleDeVoice(Me);
94         }
95         
96 };
97
98
99 extern "C" void * init_module( void )
100 {
101         return new ModuleDeVoiceFactory;
102 }