]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
Refactor port binding, warning not yet tested fully
[user/henk/code/inspircd.git] / src / modules / m_devoice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /*
15  * DEVOICE module for InspIRCd
16  *  Syntax: /DEVOICE <#chan>
17  */
18
19 /* $ModDesc: Provides voiced users with the ability to devoice themselves. */
20
21 #include <stdio.h>
22 #include "users.h"
23 #include "channels.h"
24 #include "modules.h"
25 #include "inspircd.h"
26
27 /** Handle /DEVOICE
28  */
29 class cmd_devoice : public command_t
30 {
31  public:
32         cmd_devoice (InspIRCd* Instance) : command_t(Instance,"DEVOICE", 0, 1)
33         {
34                 this->source = "m_devoice.so";
35                 syntax = "<channel>";
36         }
37
38         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
39         {
40                 chanrec* c = ServerInstance->FindChan(parameters[0]);
41                 if (c && c->HasUser(user))
42                 {
43                         const char* modes[3];
44                         modes[0] = parameters[0];
45                         modes[1] = "-v";
46                         modes[2] = user->nick;
47
48                         userrec* n = new userrec(ServerInstance);
49                         n->SetFd(FD_MAGIC_NUMBER);
50                         ServerInstance->SendMode(modes,3,n);
51                         delete n;
52
53                         /* route it */
54                         return CMD_SUCCESS;
55                 }
56
57                 return CMD_FAILURE;
58         }
59 };
60
61 class ModuleDeVoice : public Module
62 {
63         cmd_devoice *mycommand;
64  public:
65         ModuleDeVoice(InspIRCd* Me) : Module::Module(Me)
66         {
67
68                 mycommand = new cmd_devoice(ServerInstance);
69                 ServerInstance->AddCommand(mycommand);
70         }
71
72         virtual ~ModuleDeVoice()
73         {
74         }
75
76         virtual Version GetVersion()
77         {
78                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
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(InspIRCd* Me)
95         {
96                 return new ModuleDeVoice(Me);
97         }
98
99 };
100
101
102 extern "C" void * init_module( void )
103 {
104         return new ModuleDeVoiceFactory;
105 }