Anope IRC Services  Version 2.0
os_kill.cpp
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 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->nick, 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 {
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 
void Kill(const MessageSource &source, const Anope::string &reason)
Definition: users.cpp:729
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_kill.cpp:44
#define ACCESS_DENIED
Definition: language.h:73
Definition: users.h:34
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_kill.cpp:23
CommandOSKill(Module *creator)
Definition: os_kill.cpp:17
#define NICK_X_NOT_IN_USE
Definition: language.h:80
bool IsProtected()
Definition: users.cpp:724
Definition: Config.cs:26
#define anope_override
Definition: services.h:56
bool empty() const
Definition: anope.h:126
#define MODULE_INIT(x)
Definition: modules.h:45
Server * server
Definition: users.h:77
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
Anope::string nick
Definition: users.h:62
static User * Find(const Anope::string &name, bool nick_only=false)
Definition: users.cpp:815
CoreExport Server * Me
Definition: servers.cpp:24
void SendSyntax(CommandSource &)
Definition: command.cpp:145
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
CommandOSKill commandoskill
Definition: os_kill.cpp:57
#define _(x)
Definition: services.h:50
OSKill(const Anope::string &modname, const Anope::string &creator)
Definition: os_kill.cpp:60