The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_devoice.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 /*
00015  * DEVOICE module for InspIRCd
00016  *  Syntax: /DEVOICE <#chan>
00017  */
00018 
00019 /* $ModDesc: Provides voiced users with the ability to devoice themselves. */
00020 
00021 #include "inspircd.h"
00022 
00025 class CommandDevoice : public Command
00026 {
00027  public:
00028         CommandDevoice (InspIRCd* Instance) : Command(Instance,"DEVOICE", 0, 1)
00029         {
00030                 this->source = "m_devoice.so";
00031                 syntax = "<channel>";
00032                 TRANSLATE2(TR_TEXT, TR_END);
00033         }
00034 
00035         CmdResult Handle (const std::vector<std::string> &parameters, User *user)
00036         {
00037                 Channel* c = ServerInstance->FindChan(parameters[0]);
00038                 if (c && c->HasUser(user))
00039                 {
00040                         std::vector<std::string> modes;
00041                         modes.push_back(parameters[0]);
00042                         modes.push_back("-v");
00043                         modes.push_back(user->nick);
00044 
00045                         ServerInstance->SendMode(modes, ServerInstance->FakeClient);
00046 
00047                         /* route it -- SendMode doesn't distribute over the whole network */
00048                         return CMD_SUCCESS;
00049                 }
00050 
00051                 return CMD_FAILURE;
00052         }
00053 };
00054 
00055 class ModuleDeVoice : public Module
00056 {
00057         CommandDevoice *mycommand;
00058  public:
00059         ModuleDeVoice(InspIRCd* Me) : Module(Me)
00060         {
00061 
00062                 mycommand = new CommandDevoice(ServerInstance);
00063                 ServerInstance->AddCommand(mycommand);
00064 
00065         }
00066 
00067         virtual ~ModuleDeVoice()
00068         {
00069         }
00070 
00071         virtual Version GetVersion()
00072         {
00073                 return Version("$Id: m_devoice.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00074         }
00075 };
00076 
00077 MODULE_INIT(ModuleDeVoice)