Anope IRC Services  Version 2.0
ns_logout.cpp
Go to the documentation of this file.
1 /* NickServ 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 static ServiceReference<NickServService> NickServService("NickServService", "NickServ");
15 
16 class CommandNSLogout : public Command
17 {
18  public:
19  CommandNSLogout(Module *creator) : Command(creator, "nickserv/logout", 0, 2)
20  {
21  this->SetDesc(_("Reverses the effect of the IDENTIFY command"));
22  this->SetSyntax(_("[\037nickname\037 [REVALIDATE]]"));
23  }
24 
25  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
26  {
27 
28  const Anope::string &nick = !params.empty() ? params[0] : "";
29  const Anope::string &param = params.size() > 1 ? params[1] : "";
30 
31  User *u2;
32  if (!source.IsServicesOper() && !nick.empty())
33  this->OnSyntaxError(source, "");
34  else if (!(u2 = (!nick.empty() ? User::Find(nick, true) : source.GetUser())))
35  source.Reply(NICK_X_NOT_IN_USE, !nick.empty() ? nick.c_str() : source.GetNick().c_str());
36  else if (!nick.empty() && u2->IsServicesOper())
37  source.Reply(_("You can't logout %s, they are a Services Operator."), nick.c_str());
38  else
39  {
40  if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServService)
42 
43  u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */
44  Log(LOG_COMMAND, source, this) << "to logout " << u2->nick;
45 
46  /* Remove founder status from this user in all channels */
47  if (!nick.empty())
48  source.Reply(_("Nick %s has been logged out."), nick.c_str());
49  else
50  source.Reply(_("Your nick has been logged out."));
51 
52  IRCD->SendLogout(u2);
53  u2->RemoveMode(source.service, "REGISTERED");
54  u2->Logout();
55 
56  /* Send out an event */
57  FOREACH_MOD(OnNickLogout, (u2));
58  }
59  return;
60  }
61 
62  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
63  {
64  this->SendSyntax(source);
65  source.Reply(" ");
66  source.Reply(_("Without a parameter, reverses the effect of the \002IDENTIFY\002\n"
67  "command, i.e. make you not recognized as the real owner of the nick\n"
68  "anymore. Note, however, that you won't be asked to reidentify\n"
69  "yourself.\n"
70  " \n"
71  "With a parameter, does the same for the given nick. If you\n"
72  "specify \002REVALIDATE\002 as well, Services will ask the given nick\n"
73  "to re-identify. This is limited to \002Services Operators\002."));
74 
75  return true;
76  }
77 };
78 
79 class NSLogout : public Module
80 {
82 
83  public:
84  NSLogout(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
85  commandnslogout(this)
86  {
87 
88  }
89 };
90 
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: ns_logout.cpp:62
static ServiceReference< NickServService > NickServService("NickServService","NickServ")
virtual void SendLogout(User *u)=0
Definition: users.h:34
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
bool equals_ci(const char *_str) const
Definition: anope.h:78
#define FOREACH_MOD(ename, args)
Definition: modules.h:62
#define NICK_X_NOT_IN_USE
Definition: language.h:80
virtual void Validate(User *u)=0
virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
Definition: command.cpp:191
CommandNSLogout commandnslogout
Definition: ns_logout.cpp:81
CommandNSLogout(Module *creator)
Definition: ns_logout.cpp:19
#define anope_override
Definition: services.h:56
bool empty() const
Definition: anope.h:126
void Logout()
Definition: users.cpp:408
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
void RemoveMode(BotInfo *bi, UserMode *um, const Anope::string &param="")
Definition: users.cpp:587
Anope::string nick
Definition: users.h:62
static User * Find(const Anope::string &name, bool nick_only=false)
Definition: users.cpp:815
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: ns_logout.cpp:25
void SendSyntax(CommandSource &)
Definition: command.cpp:145
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
bool IsServicesOper()
Definition: users.cpp:451
bool super_admin
Definition: users.h:83
NSLogout(const Anope::string &modname, const Anope::string &creator)
Definition: ns_logout.cpp:84
#define _(x)
Definition: services.h:50