]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_devoice.cpp
Merge pull request #1351 from SaberUK/master+webirc
[user/henk/code/inspircd.git] / src / modules / m_devoice.cpp
index e760db85958ca78191d5fe0ccd2ff2bbab493469..4e4b3a354b4efdb0bd7bf8c97584b36e61498251 100644 (file)
@@ -1 +1,65 @@
-/*       +------------------------------------+\r *       | Inspire Internet Relay Chat Daemon |\r *       +------------------------------------+\r *\r *  InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r *            the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r/*\r * DEVOICE module for InspIRCd\r *  Syntax: /DEVOICE <#chan>\r */\r\r/* $ModDesc: Provides voiced users with the ability to devoice themselves. */\r\r#include "inspircd.h"\r#include "users.h"\r#include "channels.h"\r#include "modules.h"\r\r/** Handle /DEVOICE\r */\rclass cmd_devoice : public command_t\r{\r public:\r   cmd_devoice (InspIRCd* Instance) : command_t(Instance,"DEVOICE", 0, 1)\r {\r              this->source = "m_devoice.so";\r         syntax = "<channel>";\r  }\r\r     CmdResult Handle (const char** parameters, int pcnt, userrec *user)\r    {\r              chanrec* c = ServerInstance->FindChan(parameters[0]);\r          if (c && c->HasUser(user))\r             {\r                      const char* modes[3];\r                  modes[0] = parameters[0];\r                      modes[1] = "-v";\r                       modes[2] = user->nick;\r\r                        userrec* n = new userrec(ServerInstance);\r                      n->SetFd(FD_MAGIC_NUMBER);\r                     ServerInstance->SendMode(modes,3,n);\r                   delete n;\r\r                     /* route it */\r                 return CMD_SUCCESS;\r            }\r\r             return CMD_FAILURE;\r    }\r};\r\rclass ModuleDeVoice : public Module\r{\r    cmd_devoice *mycommand;\r public:\r       ModuleDeVoice(InspIRCd* Me) : Module(Me)\r       {\r\r             mycommand = new cmd_devoice(ServerInstance);\r           ServerInstance->AddCommand(mycommand);\r }\r\r     virtual ~ModuleDeVoice()\r       {\r      }\r\r     virtual Version GetVersion()\r   {\r              return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);\r    }\r};\r\rMODULE_INIT(ModuleDeVoice)\r
\ No newline at end of file
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2005, 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
+ *
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/*
+ * DEVOICE module for InspIRCd
+ *  Syntax: /DEVOICE <#chan>
+ */
+
+#include "inspircd.h"
+
+/** Handle /DEVOICE
+ */
+class CommandDevoice : public Command
+{
+ public:
+       CommandDevoice(Module* Creator) : Command(Creator,"DEVOICE", 1)
+       {
+               syntax = "<channel>";
+       }
+
+       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+       {
+               std::vector<std::string> modes;
+               modes.push_back(parameters[0]);
+               modes.push_back("-v");
+               modes.push_back(user->nick);
+
+               ServerInstance->Parser.CallHandler("MODE", modes, ServerInstance->FakeClient);
+               return CMD_SUCCESS;
+       }
+};
+
+class ModuleDeVoice : public Module
+{
+       CommandDevoice cmd;
+ public:
+       ModuleDeVoice() : cmd(this)
+       {
+       }
+
+       Version GetVersion() CXX11_OVERRIDE
+       {
+               return Version("Provides voiced users with the ability to devoice themselves.", VF_VENDOR);
+       }
+};
+
+MODULE_INIT(ModuleDeVoice)