Anope IRC Services  Version 2.0
ns_drop.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 class CommandNSDrop : public Command
15 {
16  public:
17  CommandNSDrop(Module *creator) : Command(creator, "nickserv/drop", 1, 1)
18  {
19  this->SetSyntax(_("\037nickname\037"));
20  this->SetDesc(_("Cancel the registration of a nickname"));
21  }
22 
23  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
24  {
25  const Anope::string &nick = params[0];
26 
27  if (Anope::ReadOnly && !source.HasPriv("nickserv/drop"))
28  {
29  source.Reply(_("Sorry, nickname de-registration is temporarily disabled."));
30  return;
31  }
32 
33  NickAlias *na = NickAlias::Find(nick);
34  if (!na)
35  {
36  source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
37  return;
38  }
39 
40  bool is_mine = source.GetAccount() == na->nc;
41 
42  if (!is_mine && !source.HasPriv("nickserv/drop"))
43  source.Reply(ACCESS_DENIED);
44  else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper())
45  source.Reply(_("You may not drop other Services Operators' nicknames."));
46  else
47  {
48  FOREACH_MOD(OnNickDrop, (source, na));
49 
50  Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
51  delete na;
52 
53  source.Reply(_("Nickname \002%s\002 has been dropped."), nick.c_str());
54  }
55  }
56 
57  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
58  {
59  this->SendSyntax(source);
60  source.Reply(" ");
61  source.Reply(_("Drops the given nick from the database. Once your nickname\n"
62  "is dropped you may lose all of your access and channels that\n"
63  "you may own. Any other user will be able to gain control of\n"
64  "this nick."));
65  if (!source.HasPriv("nickserv/drop"))
66  source.Reply(_("You may drop any nick within your group."));
67  else
68  source.Reply(_("As a Services Operator, you may drop any nick."));
69 
70  return true;
71  }
72 };
73 
74 class NSDrop : public Module
75 {
77 
78  public:
79  NSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
80  commandnsdrop(this)
81  {
82 
83  }
84 };
85 
Serialize::Reference< NickCore > nc
Definition: account.h:47
CoreExport bool ReadOnly
Definition: main.cpp:28
static NickAlias * Find(const Anope::string &nick)
Definition: nickalias.cpp:121
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: ns_drop.cpp:57
CommandNSDrop(Module *creator)
Definition: ns_drop.cpp:17
Anope::string nick
Definition: account.h:37
#define ACCESS_DENIED
Definition: language.h:73
#define NICK_X_NOT_REGISTERED
Definition: language.h:79
NSDrop(const Anope::string &modname, const Anope::string &creator)
Definition: ns_drop.cpp:79
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
#define FOREACH_MOD(ename, args)
Definition: modules.h:62
Definition: Config.cs:26
#define anope_override
Definition: services.h:56
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: ns_drop.cpp:23
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
void SendSyntax(CommandSource &)
Definition: command.cpp:145
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
CommandNSDrop commandnsdrop
Definition: ns_drop.cpp:76
#define _(x)
Definition: services.h:50