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