]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
2e590095fcfe1a9a84b68a3863cd34728b114eae
[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(Module* Creator) : Command(Creator,"DEVOICE", 1)
29         {
30                 syntax = "<channel>";
31                 TRANSLATE2(TR_TEXT, TR_END);
32         }
33
34         CmdResult Handle (const std::vector<std::string> &parameters, User *user)
35         {
36                 Channel* c = ServerInstance->FindChan(parameters[0]);
37                 if (c && c->HasUser(user))
38                 {
39                         std::vector<std::string> modes;
40                         modes.push_back(parameters[0]);
41                         modes.push_back("-v");
42                         modes.push_back(user->nick);
43
44                         ServerInstance->SendMode(modes, ServerInstance->FakeClient);
45                         ServerInstance->PI->SendMode(c->name, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate());
46                         return CMD_SUCCESS;
47                 }
48
49                 return CMD_FAILURE;
50         }
51 };
52
53 class ModuleDeVoice : public Module
54 {
55         CommandDevoice cmd;
56  public:
57         ModuleDeVoice(InspIRCd* Me) : Module(Me), cmd(this)
58         {
59                 ServerInstance->AddCommand(&cmd);
60         }
61
62         virtual ~ModuleDeVoice()
63         {
64         }
65
66         virtual Version GetVersion()
67         {
68                 return Version("Provides voiced users with the ability to devoice themselves.", VF_VENDOR, API_VERSION);
69         }
70 };
71
72 MODULE_INIT(ModuleDeVoice)