]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
d4d018e9356b960a9d5b221fc0fad63b9fc6c4ab
[user/henk/code/inspircd.git] / src / modules / m_devoice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 CommandDevoice : public Command
26 {
27  public:
28         CommandDevoice (InspIRCd* Instance) : Command(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* const* parameters, int pcnt, User *user)
36         {
37                 Channel* 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         CommandDevoice *mycommand;
58  public:
59         ModuleDeVoice(InspIRCd* Me) : Module(Me)
60         {
61
62                 mycommand = new CommandDevoice(ServerInstance);
63                 ServerInstance->AddCommand(mycommand);
64
65         }
66
67         virtual ~ModuleDeVoice()
68         {
69         }
70
71         virtual Version GetVersion()
72         {
73                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
74         }
75 };
76
77 MODULE_INIT(ModuleDeVoice)