]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
Add a metric assload of TRANSLATE macros to modules.
[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                         userrec* n = new userrec(ServerInstance);
46                         n->SetFd(FD_MAGIC_NUMBER);
47                         ServerInstance->SendMode(modes,3,n);
48                         delete n;
49
50                         /* route it -- SendMode doesn't distribute over the whole network */
51                         return CMD_SUCCESS;
52                 }
53
54                 return CMD_FAILURE;
55         }
56 };
57
58 class ModuleDeVoice : public Module
59 {
60         cmd_devoice *mycommand;
61  public:
62         ModuleDeVoice(InspIRCd* Me) : Module(Me)
63         {
64
65                 mycommand = new cmd_devoice(ServerInstance);
66                 ServerInstance->AddCommand(mycommand);
67         }
68
69         virtual ~ModuleDeVoice()
70         {
71         }
72
73         virtual Version GetVersion()
74         {
75                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
76         }
77 };
78
79 MODULE_INIT(ModuleDeVoice)