anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

os_kill.cpp (1723B)

      1 /* OperServ core functions
      2  *
      3  * (C) 2003-2022 Anope Team
      4  * Contact us at team@anope.org
      5  *
      6  * Please read COPYING and README for further details.
      7  *
      8  * Based on the original code of Epona by Lara.
      9  * Based on the original code of Services by Andy Church.
     10  */
     11 
     12 #include "module.h"
     13 
     14 class CommandOSKill : public Command
     15 {
     16  public:
     17 	CommandOSKill(Module *creator) : Command(creator, "operserv/kill", 1, 2)
     18 	{
     19 		this->SetDesc(_("Kill a user"));
     20 		this->SetSyntax(_("\037user\037 [\037reason\037]"));
     21 	}
     22 
     23 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     24 	{
     25 		const Anope::string &nick = params[0];
     26 		Anope::string reason = params.size() > 1 ? params[1] : "";
     27 
     28 		User *u2 = User::Find(nick, true);
     29 		if (u2 == NULL)
     30 			source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
     31 		else if (u2->IsProtected() || u2->server == Me)
     32 			source.Reply(ACCESS_DENIED);
     33 		else
     34 		{
     35 			if (reason.empty())
     36 				reason = "No reason specified";
     37 			if (Config->GetModule("operserv")->Get<bool>("addakiller"))
     38 				reason = "(" + source.GetNick() + ") " + reason;
     39 			Log(LOG_ADMIN, source, this) << "on " << u2->nick << " for " << reason;
     40 			u2->Kill(*source.service, reason);
     41 		}
     42 	}
     43 
     44 	bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
     45 	{
     46 		this->SendSyntax(source);
     47 		source.Reply(" ");
     48 		source.Reply(_("Allows you to kill a user from the network.\n"
     49 				"Parameters are the same as for the standard /KILL\n"
     50 				"command."));
     51 		return true;
     52 	}
     53 };
     54 
     55 class OSKill : public Module
     56 {
     57 	CommandOSKill commandoskill;
     58 
     59  public:
     60 	OSKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
     61 		commandoskill(this)
     62 	{
     63 
     64 	}
     65 };
     66 
     67 MODULE_INIT(OSKill)