]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
5b60752f31fcf2d2f99498889d9bf5c663ae53ff
[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 "modules.h"
30 #include "inspircd.h"
31
32 extern InspIRCd* ServerInstance;
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                 ServerInstance->SendMode(modes,3,user);
57         }
58 };
59
60 class ModuleDeVoice : public Module
61 {
62         cmd_devoice *mycommand;
63  public:
64         ModuleDeVoice(InspIRCd* Me) : Module::Module(Me)
65         {
66                 
67                 mycommand = new cmd_devoice();
68                 ServerInstance->AddCommand(mycommand);
69         }
70         
71         virtual ~ModuleDeVoice()
72         {
73         }
74         
75         virtual Version GetVersion()
76         {
77                 return Version(1, 0, 0, 0, VF_VENDOR);
78         }
79 };
80
81
82 class ModuleDeVoiceFactory : public ModuleFactory
83 {
84  public:
85         ModuleDeVoiceFactory()
86         {
87         }
88         
89         ~ModuleDeVoiceFactory()
90         {
91         }
92         
93         virtual Module * CreateModule(InspIRCd* Me)
94         {
95                 return new ModuleDeVoice(Me);
96         }
97         
98 };
99
100
101 extern "C" void * init_module( void )
102 {
103         return new ModuleDeVoiceFactory;
104 }