mirror of
https://github.com/anope/anope.git
synced 2026-07-06 21:03:13 +02:00
Also use drop confirmation codes for nicknames.
This commit is contained in:
@@ -65,6 +65,7 @@ namespace Language
|
||||
} // namespace Language
|
||||
|
||||
/* Commonly used language strings */
|
||||
#define CONFIRM_DROP _("Please confirm that you want to drop \002%s\002 with \002DROP %s %s\002")
|
||||
#define MORE_INFO _("\002%s%s HELP %s\002 for more information.")
|
||||
#define BAD_USERHOST_MASK _("Mask must be in the form \037user\037@\037host\037.")
|
||||
#define BAD_EXPIRY_TIME _("Invalid expiry time.")
|
||||
|
||||
@@ -20,7 +20,7 @@ private:
|
||||
public:
|
||||
CommandCSDrop(Module *creator)
|
||||
: Command(creator, "chanserv/drop", 1, 2)
|
||||
, dropcode(creator, "dropcode")
|
||||
, dropcode(creator, "channel-dropcode")
|
||||
{
|
||||
this->SetDesc(_("Cancel the registration of a channel"));
|
||||
this->SetSyntax(_("\037channel\037 [\037code\037]"));
|
||||
@@ -54,12 +54,11 @@ public:
|
||||
{
|
||||
if (!code)
|
||||
{
|
||||
code = ci->Extend<Anope::string>("dropcode");
|
||||
code = ci->Extend<Anope::string>("channel-dropcode");
|
||||
*code = Anope::Random(15);
|
||||
}
|
||||
|
||||
source.Reply(_("Please confirm that you want to drop \002%s\002 with \002DROP %s %s\002"),
|
||||
chan.c_str(), chan.c_str(), code->c_str());
|
||||
source.Reply(CONFIRM_DROP, ci->name.c_str(), ci->name.c_str(), code->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,15 @@
|
||||
class CommandNSDrop final
|
||||
: public Command
|
||||
{
|
||||
private:
|
||||
PrimitiveExtensibleItem<Anope::string> dropcode;
|
||||
|
||||
public:
|
||||
CommandNSDrop(Module *creator) : Command(creator, "nickserv/drop", 1, 1)
|
||||
CommandNSDrop(Module *creator)
|
||||
: Command(creator, "nickserv/drop", 1, 2)
|
||||
, dropcode(creator, "nickname-dropcode")
|
||||
{
|
||||
this->SetSyntax(_("\037nickname\037"));
|
||||
this->SetSyntax(_("\037nickname\037 [\037code\037]"));
|
||||
this->SetDesc(_("Cancel the registration of a nickname"));
|
||||
}
|
||||
|
||||
@@ -41,18 +46,36 @@ public:
|
||||
bool is_mine = source.GetAccount() == na->nc;
|
||||
|
||||
if (!is_mine && !source.HasPriv("nickserv/drop"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper())
|
||||
source.Reply(_("You may not drop other Services Operators' nicknames."));
|
||||
else
|
||||
{
|
||||
FOREACH_MOD(OnNickDrop, (source, na));
|
||||
|
||||
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") << ")";
|
||||
delete na;
|
||||
|
||||
source.Reply(_("Nickname \002%s\002 has been dropped."), nick.c_str());
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper())
|
||||
{
|
||||
source.Reply(_("You may not drop other Services Operators' nicknames."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto *code = dropcode.Get(na);
|
||||
if (params.size() < 2 || !code || !code->equals_ci(params[1]))
|
||||
{
|
||||
if (!code)
|
||||
{
|
||||
code = na->Extend<Anope::string>("nickname-dropcode");
|
||||
*code = Anope::Random(15);
|
||||
}
|
||||
|
||||
source.Reply(CONFIRM_DROP, na->nick.c_str(), na->nick.c_str(), code->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
FOREACH_MOD(OnNickDrop, (source, na));
|
||||
|
||||
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") << ")";
|
||||
delete na;
|
||||
|
||||
source.Reply(_("Nickname \002%s\002 has been dropped."), nick.c_str());
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
|
||||
|
||||
Reference in New Issue
Block a user