]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
Fix crash on propogation after routed squit has reached it's destination. Thx HiroP.
[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 "inspircd.h"
22 #include "users.h"
23 #include "channels.h"
24 #include "modules.h"
25
26 /** Handle /DEVOICE
27  */
28 class cmd_devoice : public command_t
29 {
30  public:
31         cmd_devoice (InspIRCd* Instance) : command_t(Instance,"DEVOICE", 0, 1)
32         {
33                 this->source = "m_devoice.so";
34                 syntax = "<channel>";
35         }
36
37         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
38         {
39                 chanrec* c = ServerInstance->FindChan(parameters[0]);
40                 if (c && c->HasUser(user))
41                 {
42                         const char* modes[3];
43                         modes[0] = parameters[0];
44                         modes[1] = "-v";
45                         modes[2] = user->nick;
46
47                         userrec* n = new userrec(ServerInstance);
48                         n->SetFd(FD_MAGIC_NUMBER);
49                         ServerInstance->SendMode(modes,3,n);
50                         delete n;
51
52                         /* route it */
53                         return CMD_SUCCESS;
54                 }
55
56                 return CMD_FAILURE;
57         }
58 };
59
60 class ModuleDeVoice : public Module
61 {
62         cmd_devoice *mycommand;
63  public:
64         ModuleDeVoice(InspIRCd* Me) : Module(Me)
65         {
66
67                 mycommand = new cmd_devoice(ServerInstance);
68                 ServerInstance->AddCommand(mycommand);
69         }
70
71         virtual ~ModuleDeVoice()
72         {
73         }
74
75         virtual Version GetVersion()
76         {
77                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
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" DllExport void * init_module( void )
102 {
103         return new ModuleDeVoiceFactory;
104 }