]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
These commands do not need to be VF_COMMON
[user/henk/code/inspircd.git] / src / modules / m_devoice.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 std::vector<std::string> &parameters, User *user)
36         {
37                 Channel* c = ServerInstance->FindChan(parameters[0]);
38                 if (c && c->HasUser(user))
39                 {
40                         std::vector<std::string> modes;
41                         modes.push_back(parameters[0]);
42                         modes.push_back("-v");
43                         modes.push_back(user->nick);
44
45                         ServerInstance->SendMode(modes, ServerInstance->FakeClient);
46                         ServerInstance->PI->SendMode(c->name, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate());
47                         return CMD_LOCALONLY;
48                 }
49
50                 return CMD_FAILURE;
51         }
52 };
53
54 class ModuleDeVoice : public Module
55 {
56         CommandDevoice *mycommand;
57  public:
58         ModuleDeVoice(InspIRCd* Me) : Module(Me)
59         {
60
61                 mycommand = new CommandDevoice(ServerInstance);
62                 ServerInstance->AddCommand(mycommand);
63
64         }
65
66         virtual ~ModuleDeVoice()
67         {
68         }
69
70         virtual Version GetVersion()
71         {
72                 return Version("$Id$", VF_VENDOR, API_VERSION);
73         }
74 };
75
76 MODULE_INIT(ModuleDeVoice)