]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
f2c47cc9afe22e27e2990b17edf631314489101b
[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
23 /** Handle /DEVOICE
24  */
25 class cmd_devoice : public command_t
26 {
27  public:
28         cmd_devoice (InspIRCd* Instance) : command_t(Instance,"DEVOICE", 0, 1)
29         {
30                 this->source = "m_devoice.so";
31                 syntax = "<channel>";
32                 TRANSLATE2(TR_TEXT, TR_END);
33         }
34
35         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
36         {
37                 chanrec* c = ServerInstance->FindChan(parameters[0]);
38                 if (c && c->HasUser(user))
39                 {
40                         const char* modes[3];
41                         modes[0] = parameters[0];
42                         modes[1] = "-v";
43                         modes[2] = user->nick;
44
45                         ServerInstance->SendMode(modes, 3, ServerInstance->FakeClient);
46
47                         /* route it -- SendMode doesn't distribute over the whole network */
48                         return CMD_SUCCESS;
49                 }
50
51                 return CMD_FAILURE;
52         }
53 };
54
55 class ModuleDeVoice : public Module
56 {
57         cmd_devoice *mycommand;
58  public:
59         ModuleDeVoice(InspIRCd* Me) : Module(Me)
60         {
61
62                 mycommand = new cmd_devoice(ServerInstance);
63                 ServerInstance->AddCommand(mycommand);
64         }
65
66         virtual ~ModuleDeVoice()
67         {
68         }
69
70         virtual Version GetVersion()
71         {
72                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
73         }
74 };
75
76 MODULE_INIT(ModuleDeVoice)