anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

ns_drop.cpp (2425B)

      1 /* NickServ core functions
      2  *
      3  * (C) 2003-2022 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 {
     76 	CommandNSDrop commandnsdrop;
     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 
     86 MODULE_INIT(NSDrop)