]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
Made SANICK not collide the user (theres no need to in the new 1.1 now we have return...
[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
33          
34 class cmd_devoice : public command_t
35 {
36  public:
37         cmd_devoice (InspIRCd* Instance) : command_t(Instance,"DEVOICE", 0, 1)
38         {
39                 this->source = "m_devoice.so";
40                 syntax = "<channel>";
41         }
42
43         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
44         {
45                 chanrec* c = ServerInstance->FindChan(parameters[0]);
46                 if (c && c->HasUser(user))
47                 {
48                         const char* modes[3];
49                         modes[0] = parameters[0];
50                         modes[1] = "-v";
51                         modes[2] = user->nick;
52
53                         ServerInstance->SendMode(modes,3,user);
54
55                         return CMD_SUCCESS;
56                 }
57
58                 return CMD_FAILURE;
59         }
60 };
61
62 class ModuleDeVoice : public Module
63 {
64         cmd_devoice *mycommand;
65  public:
66         ModuleDeVoice(InspIRCd* Me) : Module::Module(Me)
67         {
68                 
69                 mycommand = new cmd_devoice(ServerInstance);
70                 ServerInstance->AddCommand(mycommand);
71         }
72         
73         virtual ~ModuleDeVoice()
74         {
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1, 0, 0, 0, VF_VENDOR);
80         }
81 };
82
83
84 class ModuleDeVoiceFactory : public ModuleFactory
85 {
86  public:
87         ModuleDeVoiceFactory()
88         {
89         }
90         
91         ~ModuleDeVoiceFactory()
92         {
93         }
94         
95         virtual Module * CreateModule(InspIRCd* Me)
96         {
97                 return new ModuleDeVoice(Me);
98         }
99         
100 };
101
102
103 extern "C" void * init_module( void )
104 {
105         return new ModuleDeVoiceFactory;
106 }