summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/language.h1
-rw-r--r--modules/chanserv/cs_drop.cpp7
-rw-r--r--modules/nickserv/ns_drop.cpp41
3 files changed, 36 insertions, 13 deletions
diff --git a/include/language.h b/include/language.h
index a0ca020d9..8dfd004c1 100644
--- a/include/language.h
+++ b/include/language.h
@@ -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.")
diff --git a/modules/chanserv/cs_drop.cpp b/modules/chanserv/cs_drop.cpp
index eada1c23b..cfeeddbdb 100644
--- a/modules/chanserv/cs_drop.cpp
+++ b/modules/chanserv/cs_drop.cpp
@@ -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;
}
diff --git a/modules/nickserv/ns_drop.cpp b/modules/nickserv/ns_drop.cpp
index dbdbe09be..a315deab5 100644
--- a/modules/nickserv/ns_drop.cpp
+++ b/modules/nickserv/ns_drop.cpp
@@ -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
+ return;
+ }
+
+ if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper())
{
- FOREACH_MOD(OnNickDrop, (source, na));
+ source.Reply(_("You may not drop other Services Operators' nicknames."));
+ return;
+ }
- 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;
+ 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(_("Nickname \002%s\002 has been dropped."), nick.c_str());
+ 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