]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_devoice.cpp
Change to use std::string::iterator rather than making a copy of the pointer and...
[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 <stdio.h>
22 #include "users.h"
23 #include "channels.h"
24 #include "modules.h"
25 #include "inspircd.h"
26
27 /** Handle /DEVOICE
28  */      
29 class cmd_devoice : public command_t
30 {
31  public:
32         cmd_devoice (InspIRCd* Instance) : command_t(Instance,"DEVOICE", 0, 1)
33         {
34                 this->source = "m_devoice.so";
35                 syntax = "<channel>";
36         }
37
38         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
39         {
40                 chanrec* c = ServerInstance->FindChan(parameters[0]);
41                 if (c && c->HasUser(user))
42                 {
43                         const char* modes[3];
44                         modes[0] = parameters[0];
45                         modes[1] = "-v";
46                         modes[2] = user->nick;
47
48                         ServerInstance->SendMode(modes,3,user);
49
50                         return CMD_SUCCESS;
51                 }
52
53                 return CMD_FAILURE;
54         }
55 };
56
57 class ModuleDeVoice : public Module
58 {
59         cmd_devoice *mycommand;
60  public:
61         ModuleDeVoice(InspIRCd* Me) : Module::Module(Me)
62         {
63                 
64                 mycommand = new cmd_devoice(ServerInstance);
65                 ServerInstance->AddCommand(mycommand);
66         }
67         
68         virtual ~ModuleDeVoice()
69         {
70         }
71         
72         virtual Version GetVersion()
73         {
74                 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
75         }
76 };
77
78
79 class ModuleDeVoiceFactory : public ModuleFactory
80 {
81  public:
82         ModuleDeVoiceFactory()
83         {
84         }
85         
86         ~ModuleDeVoiceFactory()
87         {
88         }
89         
90         virtual Module * CreateModule(InspIRCd* Me)
91         {
92                 return new ModuleDeVoice(Me);
93         }
94         
95 };
96
97
98 extern "C" void * init_module( void )
99 {
100         return new ModuleDeVoiceFactory;
101 }