diff options
Diffstat (limited to 'modules/chanserv/cs_drop.cpp')
-rw-r--r-- | modules/chanserv/cs_drop.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/modules/chanserv/cs_drop.cpp b/modules/chanserv/cs_drop.cpp index fa613efa7..2bc0e76a7 100644 --- a/modules/chanserv/cs_drop.cpp +++ b/modules/chanserv/cs_drop.cpp @@ -14,11 +14,16 @@ class CommandCSDrop final : public Command { +private: + PrimitiveExtensibleItem<Anope::string> dropcode; + public: - CommandCSDrop(Module *creator) : Command(creator, "chanserv/drop", 1, 2) + CommandCSDrop(Module *creator) + : Command(creator, "chanserv/drop", 1, 2) + , dropcode(creator, "dropcode") { this->SetDesc(_("Cancel the registration of a channel")); - this->SetSyntax(_("\037channel\037 \037channel\037")); + this->SetSyntax(_("\037channel\037 [\037code\037]")); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override @@ -38,22 +43,33 @@ public: return; } - if (params.size() < 2 || !chan.equals_ci(params[1])) + if ((ci->HasExt("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) { - source.Reply(_("You must enter the channel name twice as a confirmation that you wish to drop \002%s\002."), chan.c_str()); + source.Reply(ACCESS_DENIED); return; } - if ((ci->HasExt("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) + auto *code = dropcode.Get(ci); + if (params.size() < 2 || !code || !code->equals_ci(params[1])) { - source.Reply(ACCESS_DENIED); + if (!code) + { + code = ci->Extend<Anope::string>("dropcode"); + *code = Anope::Random(15); + } + + source.Reply(_("Please confirm that you want to drop \002%s\002 with with \002DROP %s %s\002."), + chan.c_str(), chan.c_str(), code->c_str()); return; } EventReturn MOD_RESULT; FOREACH_RESULT(OnChanDrop, MOD_RESULT, (source, ci)); if (MOD_RESULT == EVENT_STOP) + { + dropcode.Unset(ci); return; + } bool override = (ci->HasExt("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; |