Anope IRC Services  Version 2.0
os_oline.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 CommandOSOLine : public Command
15 {
16  public:
17  CommandOSOLine(Module *creator) : Command(creator, "operserv/oline", 2, 2)
18  {
19  this->SetDesc(_("Give Operflags to a certain user"));
20  this->SetSyntax(_("\037nick\037 \037flags\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  const Anope::string &flag = params[1];
27  User *u2 = NULL;
28 
29  /* let's check whether the user is online */
30  if (!(u2 = User::Find(nick, true)))
31  source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
32  else if (u2 && flag[0] == '+')
33  {
34  IRCD->SendSVSO(source.service, nick, flag);
35  u2->SetMode(source.service, "OPER");
36  u2->SendMessage(source.service, _("You are now an IRC Operator."));
37  source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str());
38  Log(LOG_ADMIN, source, this) << "for " << nick;
39  }
40  else if (u2 && flag[0] == '-')
41  {
42  IRCD->SendSVSO(source.service, nick, flag);
43  source.Reply(_("Operflags \002%s\002 have been removed from \002%s\002."), flag.c_str(), nick.c_str());
44  Log(LOG_ADMIN, source, this) << "for " << nick;
45  }
46  else
47  this->OnSyntaxError(source, "");
48 
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 Services Operators to give Operflags to any user.\n"
57  "Flags have to be prefixed with a \"+\" or a \"-\". To\n"
58  "remove all flags simply type a \"-\" instead of any flags."));
59  return true;
60  }
61 };
62 
63 class OSOLine : public Module
64 {
66 
67  public:
68  OSOLine(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
69  commandosoline(this)
70  {
71 
72  if (!IRCD || !IRCD->CanSVSO)
73  throw ModuleException("Your IRCd does not support OMODE.");
74 
75  }
76 };
77 
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_oline.cpp:23
void SetMode(BotInfo *bi, UserMode *um, const Anope::string &param="")
Definition: users.cpp:573
CommandOSOLine(Module *creator)
Definition: os_oline.cpp:17
virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &)
Definition: protocol.h:185
Definition: users.h:34
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
#define NICK_X_NOT_IN_USE
Definition: language.h:80
virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
Definition: command.cpp:191
CommandOSOLine commandosoline
Definition: os_oline.cpp:65
bool CanSVSO
Definition: protocol.h:65
#define anope_override
Definition: services.h:56
CoreExport IRCDProto * IRCD
Definition: protocol.cpp:23
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
static User * Find(const Anope::string &name, bool nick_only=false)
Definition: users.cpp:815
void SendSyntax(CommandSource &)
Definition: command.cpp:145
OSOLine(const Anope::string &modname, const Anope::string &creator)
Definition: os_oline.cpp:68
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_oline.cpp:52
void SendMessage(BotInfo *source, const char *fmt,...)
Definition: users.cpp:320
#define _(x)
Definition: services.h:50