Anope IRC Services  Version 2.0
os_kick.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 CommandOSKick : public Command
15 {
16  public:
17  CommandOSKick(Module *creator) : Command(creator, "operserv/kick", 3, 3)
18  {
19  this->SetDesc(_("Kick a user from a channel"));
20  this->SetSyntax(_("\037channel\037 \037user\037 \037reason\037"));
21  }
22 
23  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
24  {
25  const Anope::string &chan = params[0];
26  const Anope::string &nick = params[1];
27  const Anope::string &s = params[2];
28  Channel *c;
29  User *u2;
30 
31  if (!(c = Channel::Find(chan)))
32  {
33  source.Reply(CHAN_X_NOT_IN_USE, chan.c_str());
34  return;
35  }
36  else if (c->bouncy_modes)
37  {
38  source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?"));
39  return;
40  }
41  else if (!(u2 = User::Find(nick, true)))
42  {
43  source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
44  return;
45  }
46 
47  c->Kick(source.service, u2, "%s (%s)", source.GetNick().c_str(), s.c_str());
48  Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")";
49  return;
50  }
51 
52  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
53  {
54  this->SendSyntax(source);
55  source.Reply(" ");
56  source.Reply(_("Allows staff to kick a user from any channel.\n"
57  "Parameters are the same as for the standard /KICK\n"
58  "command. The kick message will have the nickname of the\n"
59  "IRCop sending the KICK command prepended; for example:\n"
60  " \n"
61  "*** SpamMan has been kicked off channel #my_channel by %s (Alcan (Flood))"), source.service->nick.c_str());
62  return true;
63  }
64 };
65 
66 class OSKick : public Module
67 {
69 
70  public:
71  OSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
72  commandoskick(this)
73  {
74 
75  }
76 };
77 
OSKick(const Anope::string &modname, const Anope::string &creator)
Definition: os_kick.cpp:71
CommandOSKick(Module *creator)
Definition: os_kick.cpp:17
#define CHAN_X_NOT_IN_USE
Definition: language.h:85
Definition: users.h:34
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
Anope::string name
Definition: channels.h:44
#define NICK_X_NOT_IN_USE
Definition: language.h:80
int16_t bouncy_modes
Definition: channels.h:74
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_kick.cpp:23
CommandOSKick commandoskick
Definition: os_kick.cpp:68
#define anope_override
Definition: services.h:56
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
Anope::string nick
Definition: users.h:62
bool Kick(BotInfo *bi, User *u, const char *reason=NULL,...)
Definition: channels.cpp:762
static User * Find(const Anope::string &name, bool nick_only=false)
Definition: users.cpp:815
static Channel * Find(const Anope::string &name)
Definition: channels.cpp:920
void SendSyntax(CommandSource &)
Definition: command.cpp:145
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_kick.cpp:52
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
#define _(x)
Definition: services.h:50