From f9911dde529adf3dc03f4f14bbd70756ac2f665c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 2 Mar 2025 14:51:02 +0000 Subject: Return references instead of pointers from the config system. We used to return NULL from these methods but now we return an empty block so this can never actually be null now. --- modules/nickserv/nickserv.cpp | 56 +++++++++++++++++------------------ modules/nickserv/ns_ajoin.cpp | 4 +-- modules/nickserv/ns_cert.cpp | 10 +++---- modules/nickserv/ns_drop.cpp | 4 +-- modules/nickserv/ns_group.cpp | 14 ++++----- modules/nickserv/ns_identify.cpp | 2 +- modules/nickserv/ns_list.cpp | 4 +-- modules/nickserv/ns_maxemail.cpp | 6 ++-- modules/nickserv/ns_recover.cpp | 8 ++--- modules/nickserv/ns_register.cpp | 48 +++++++++++++++--------------- modules/nickserv/ns_resetpass.cpp | 10 +++---- modules/nickserv/ns_set.cpp | 32 ++++++++++---------- modules/nickserv/ns_set_keepmodes.cpp | 2 +- modules/nickserv/ns_set_kill.cpp | 4 +-- modules/nickserv/ns_set_misc.cpp | 12 ++++---- modules/nickserv/ns_suspend.cpp | 8 ++--- 16 files changed, 112 insertions(+), 112 deletions(-) (limited to 'modules/nickserv') diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp index 25d9a364e..7d34061c7 100644 --- a/modules/nickserv/nickserv.cpp +++ b/modules/nickserv/nickserv.cpp @@ -98,7 +98,7 @@ class NickServRelease final public: NickServRelease(Module *me, NickAlias *na, time_t delay) - : User(na->nick, Config->GetModule(me)->Get("enforceruser", "user"), Config->GetModule(me)->Get("enforcerhost", Me->GetName()), "", "", Me, "Services Enforcer", Anope::CurTime, "", {}, IRCD->UID_Retrieve(), NULL) + : User(na->nick, Config->GetModule(me).Get("enforceruser", "user"), Config->GetModule(me).Get("enforcerhost", Me->GetName()), "", "", Me, "Services Enforcer", Anope::CurTime, "", {}, IRCD->UID_Retrieve(), NULL) , Timer(me, delay) , nick(na->nick) { @@ -140,12 +140,12 @@ class NickServCore final { collided.Unset(na); - new NickServHeld(this, na, Config->GetModule(this)->Get("releasetimeout", "1m")); + new NickServHeld(this, na, Config->GetModule(this).Get("releasetimeout", "1m")); if (IRCD->CanSVSHold) - IRCD->SendSVSHold(na->nick, Config->GetModule(this)->Get("releasetimeout", "1m")); + IRCD->SendSVSHold(na->nick, Config->GetModule(this).Get("releasetimeout", "1m")); else - new NickServRelease(this, na, Config->GetModule(this)->Get("releasetimeout", "1m")); + new NickServRelease(this, na, Config->GetModule(this).Get("releasetimeout", "1m")); } } @@ -176,7 +176,7 @@ public: bool IsGuestNick(const Anope::string &nick) const override { - const auto guestnick = Config->GetModule(this)->Get("guestnick", "Guest####"); + const auto guestnick = Config->GetModule(this).Get("guestnick", "Guest####"); if (guestnick.empty()) return false; // No guest nick. @@ -208,7 +208,7 @@ public: else if (MOD_RESULT == EVENT_ALLOW) return; - if (Config->GetModule("nickserv")->Get("nonicknameownership")) + if (Config->GetModule("nickserv").Get("nonicknameownership")) return; if (!na->nc->HasExt("KILL_IMMED")) @@ -224,13 +224,13 @@ public: } else if (na->nc->HasExt("KILL_QUICK")) { - time_t killquick = Config->GetModule("nickserv")->Get("killquick", "20s"); + time_t killquick = Config->GetModule("nickserv").Get("killquick", "20s"); u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(killquick, u->Account()).c_str()); new NickServCollide(this, this, u, na, killquick); } else { - time_t kill = Config->GetModule("nickserv")->Get("kill", "60s"); + time_t kill = Config->GetModule("nickserv").Get("kill", "60s"); u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(kill, u->Account()).c_str()); new NickServCollide(this, this, u, na, kill); } @@ -241,10 +241,10 @@ public: void OnUserLogin(User *u) override { NickAlias *na = NickAlias::Find(u->nick); - if (na && *na->nc == u->Account() && !Config->GetModule("nickserv")->Get("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED")) + if (na && *na->nc == u->Account() && !Config->GetModule("nickserv").Get("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); - const Anope::string &modesonid = Config->GetModule(this)->Get("modesonid"); + const Anope::string &modesonid = Config->GetModule(this).Get("modesonid"); if (!modesonid.empty()) u->SetModes(NickServ, modesonid); } @@ -261,7 +261,7 @@ public: for (auto i = 0; i < 10; ++i) { guestnick.clear(); - for (auto guestnickchr : Config->GetModule(this)->Get("guestnick", "Guest####").substr(0, IRCD->MaxNick)) + for (auto guestnickchr : Config->GetModule(this).Get("guestnick", "Guest####").substr(0, IRCD->MaxNick)) { if (guestnickchr == '#') guestnick.append(Anope::ToString(abs(Anope::RandomNumber()) % 10)); @@ -319,9 +319,9 @@ public: collided.Unset(na); /* clear pending collide */ } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - const Anope::string &nsnick = conf->GetModule(this)->Get("client"); + const Anope::string &nsnick = conf.GetModule(this).Get("client"); if (nsnick.empty()) throw ConfigException(Module::name + ": must be defined"); @@ -332,7 +332,7 @@ public: NickServ = bi; - spacesepstream(conf->GetModule(this)->Get("defaults", "memo_signon memo_receive")).GetTokens(defaults); + spacesepstream(conf.GetModule(this).Get("defaults", "memo_signon memo_receive")).GetTokens(defaults); if (defaults.empty()) { defaults.emplace_back("MEMO_SIGNON"); @@ -376,9 +376,9 @@ public: void OnNickIdentify(User *u) override { - Configuration::Block *block = Config->GetModule(this); + Configuration::Block &block = Config->GetModule(this); - if (block->Get("modeonid", "yes")) + if (block.Get("modeonid", "yes")) { for (const auto &[_, cc] : u->chans) { @@ -388,11 +388,11 @@ public: } } - const Anope::string &modesonid = block->Get("modesonid"); + const Anope::string &modesonid = block.Get("modesonid"); if (!modesonid.empty()) u->SetModes(NickServ, modesonid); - if (block->Get("forceemail", "yes") && u->Account()->email.empty()) + if (block.Get("forceemail", "yes") && u->Account()->email.empty()) { u->SendMessage(NickServ, _("You must now supply an email for your nick.\n" "This email will allow you to retrieve your password in\n" @@ -434,8 +434,8 @@ public: const NickAlias *na = NickAlias::Find(u->nick); - const Anope::string &unregistered_notice = Config->GetModule(this)->Get("unregistered_notice"); - if (!Config->GetModule("nickserv")->Get("nonicknameownership") && !unregistered_notice.empty() && !na && !u->IsIdentified()) + const Anope::string &unregistered_notice = Config->GetModule(this).Get("unregistered_notice"); + if (!Config->GetModule("nickserv").Get("nonicknameownership") && !unregistered_notice.empty() && !na && !u->IsIdentified()) u->SendMessage(NickServ, unregistered_notice.replace_all_cs("%n", u->nick)); else if (na && !u->IsIdentified(true)) this->Validate(u); @@ -477,7 +477,7 @@ public: { /* Reset +r and re-send account (even though it really should be set at this point) */ IRCD->SendLogin(u, na); - if (!Config->GetModule("nickserv")->Get("nonicknameownership") && na->nc == u->Account() && !na->nc->HasExt("UNCONFIRMED")) + if (!Config->GetModule("nickserv").Get("nonicknameownership") && na->nc == u->Account() && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); Log(u, "", NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->display; } @@ -496,7 +496,7 @@ public: { if (!params.empty() || source.c || source.service != *NickServ) return EVENT_CONTINUE; - if (!Config->GetModule("nickserv")->Get("nonicknameownership")) + if (!Config->GetModule("nickserv").Get("nonicknameownership")) source.Reply(_("\002%s\002 allows you to register a nickname and\n" "prevent others from using it. The following\n" "commands allow for registration and maintenance of\n" @@ -521,7 +521,7 @@ public: "Services Operators can also drop any nickname without needing\n" "to identify for the nick, and may view the access list for\n" "any nickname.")); - time_t nickserv_expire = Config->GetModule(this)->Get("expire", "1y"); + time_t nickserv_expire = Config->GetModule(this).Get("expire", "1y"); if (nickserv_expire >= 86400) source.Reply(_(" \n" "Accounts that are not used anymore are subject to\n" @@ -538,7 +538,7 @@ public: void OnUserQuit(User *u, const Anope::string &msg) override { - if (u->server && !u->server->GetQuitReason().empty() && Config->GetModule(this)->Get("hidenetsplitquit")) + if (u->server && !u->server->GetQuitReason().empty() && Config->GetModule(this).Get("hidenetsplitquit")) return; /* Update last quit and last seen for the user */ @@ -555,7 +555,7 @@ public: if (Anope::NoExpire || Anope::ReadOnly) return; - time_t nickserv_expire = Config->GetModule(this)->Get("expire", "90d"); + time_t nickserv_expire = Config->GetModule(this).Get("expire", "90d"); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ) { @@ -571,7 +571,7 @@ public: if (nickserv_expire && Anope::CurTime - na->last_seen >= nickserv_expire) expire = true; - if (na->nc->na == na && na->nc->aliases->size() > 1 && Config->GetModule("nickserv")->Get("preservedisplay")) + if (na->nc->na == na && na->nc->aliases->size() > 1 && Config->GetModule("nickserv").Get("preservedisplay")) expire = false; FOREACH_MOD(OnPreNickExpire, (na, expire)); @@ -589,13 +589,13 @@ public: { if (!na->nc->HasExt("UNCONFIRMED")) { - time_t nickserv_expire = Config->GetModule(this)->Get("expire", "1y"); + time_t nickserv_expire = Config->GetModule(this).Get("expire", "1y"); if (!na->HasExt("NS_NO_EXPIRE") && nickserv_expire && !Anope::NoExpire && (source.HasPriv("nickserv/auspex") || na->last_seen != Anope::CurTime)) info[_("Expires")] = Anope::strftime(na->last_seen + nickserv_expire, source.GetAccount()); } else { - time_t unconfirmed_expire = Config->GetModule("ns_register")->Get("unconfirmedexpire", "1d"); + time_t unconfirmed_expire = Config->GetModule("ns_register").Get("unconfirmedexpire", "1d"); info[_("Expires")] = Anope::strftime(na->time_registered + unconfirmed_expire, source.GetAccount()); } } diff --git a/modules/nickserv/ns_ajoin.cpp b/modules/nickserv/ns_ajoin.cpp index 8643a2c1b..a169022b1 100644 --- a/modules/nickserv/ns_ajoin.cpp +++ b/modules/nickserv/ns_ajoin.cpp @@ -139,9 +139,9 @@ class CommandNSAJoin final if ((*channels)->at(i)->channel.equals_ci(chan)) break; - if ((*channels)->size() >= Config->GetModule(this->owner)->Get("ajoinmax")) + if ((*channels)->size() >= Config->GetModule(this->owner).Get("ajoinmax")) { - source.Reply(_("Sorry, the maximum of %d auto join entries has been reached."), Config->GetModule(this->owner)->Get("ajoinmax")); + source.Reply(_("Sorry, the maximum of %d auto join entries has been reached."), Config->GetModule(this->owner).Get("ajoinmax")); return; } else if (i != (*channels)->size()) diff --git a/modules/nickserv/ns_cert.cpp b/modules/nickserv/ns_cert.cpp index 9a697df17..15f6dbab8 100644 --- a/modules/nickserv/ns_cert.cpp +++ b/modules/nickserv/ns_cert.cpp @@ -204,7 +204,7 @@ private: void DoAdd(CommandSource &source, NickCore *nc, Anope::string certfp) { NSCertList *cl = nc->Require("certificates"); - unsigned max = Config->GetModule(this->owner)->Get("max", "5"); + unsigned max = Config->GetModule(this->owner).Get("max", "5"); if (cl->GetCertCount() >= max) { @@ -325,7 +325,7 @@ public: source.Reply(ACCESS_DENIED); return; } - else if (Config->GetModule("nickserv")->Get("secureadmins", "yes") && source.GetAccount() != na->nc && na->nc->IsServicesOper() && !cmd.equals_ci("LIST")) + else if (Config->GetModule("nickserv").Get("secureadmins", "yes") && source.GetAccount() != na->nc && na->nc->IsServicesOper() && !cmd.equals_ci("LIST")) { source.Reply(_("You may view but not modify the certificate list of other Services Operators.")); return; @@ -401,7 +401,7 @@ public: if (!nc || nc->HasExt("NS_SUSPENDED")) return; - unsigned int maxlogins = Config->GetModule("ns_identify")->Get("maxlogins"); + unsigned int maxlogins = Config->GetModule("ns_identify").Get("maxlogins"); if (maxlogins && nc->users.size() >= maxlogins) { u->SendMessage(NickServ, _("Account \002%s\002 has already reached the maximum number of simultaneous logins (%u)."), nc->display.c_str(), maxlogins); @@ -420,7 +420,7 @@ public: void OnNickRegister(User *u, NickAlias *na, const Anope::string &pass) override { - if (!Config->GetModule(this)->Get("automatic", "yes") || !u || u->fingerprint.empty()) + if (!Config->GetModule(this).Get("automatic", "yes") || !u || u->fingerprint.empty()) return; auto *cl = certs.Require(na->nc); @@ -437,7 +437,7 @@ public: { BotInfo *NickServ = Config->GetClient("NickServ"); - unsigned int maxlogins = Config->GetModule("ns_identify")->Get("maxlogins"); + unsigned int maxlogins = Config->GetModule("ns_identify").Get("maxlogins"); if (maxlogins && na->nc->users.size() >= maxlogins) { u->SendMessage(NickServ, _("Account \002%s\002 has already reached the maximum number of simultaneous logins (%u)."), na->nc->display.c_str(), maxlogins); diff --git a/modules/nickserv/ns_drop.cpp b/modules/nickserv/ns_drop.cpp index 791db0bfb..f2e152ce8 100644 --- a/modules/nickserv/ns_drop.cpp +++ b/modules/nickserv/ns_drop.cpp @@ -51,13 +51,13 @@ public: return; } - if (Config->GetModule("nickserv")->Get("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper()) + if (Config->GetModule("nickserv").Get("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper()) { source.Reply(_("You may not drop other Services Operators' nicknames.")); return; } - if (na->nc->na == na && na->nc->aliases->size() > 1 && Config->GetModule("nickserv")->Get("preservedisplay") && !source.HasPriv("nickserv/drop/display")) + if (na->nc->na == na && na->nc->aliases->size() > 1 && Config->GetModule("nickserv").Get("preservedisplay") && !source.HasPriv("nickserv/drop/display")) { source.Reply(_("You may not drop \002%s\002 as it is the display nick for the account."), na->nick.c_str()); return; diff --git a/modules/nickserv/ns_group.cpp b/modules/nickserv/ns_group.cpp index 47d8066e0..69df8d16e 100644 --- a/modules/nickserv/ns_group.cpp +++ b/modules/nickserv/ns_group.cpp @@ -138,7 +138,7 @@ public: return; } - if (Config->GetModule("nickserv")->Get("restrictopernicks")) + if (Config->GetModule("nickserv").Get("restrictopernicks")) { for (auto *o : Oper::opers) { @@ -151,8 +151,8 @@ public: } NickAlias *target, *na = NickAlias::Find(source.GetNick()); - time_t reg_delay = Config->GetModule("nickserv")->Get("regdelay"); - unsigned maxaliases = Config->GetModule(this->owner)->Get("maxaliases"); + time_t reg_delay = Config->GetModule("nickserv").Get("regdelay"); + unsigned maxaliases = Config->GetModule(this->owner).Get("maxaliases"); if (!(target = NickAlias::Find(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (user && Anope::CurTime < user->lastnickreg + reg_delay) @@ -165,7 +165,7 @@ public: Log(LOG_COMMAND, source, this) << "and tried to group to SUSPENDED nick " << target->nick; source.Reply(NICK_X_SUSPENDED, target->nick.c_str()); } - else if (na && Config->GetModule(this->owner)->Get("nogroupchange")) + else if (na && Config->GetModule(this->owner).Get("nogroupchange")) source.Reply(_("Your nick is already registered.")); else if (na && *target->nc == *na->nc) source.Reply(_("You are already a member of the group of \002%s\002."), target->nick.c_str()); @@ -336,8 +336,8 @@ public: ListFormatter list(source.GetAccount()); list.AddColumn(_("Nick")).AddColumn(_("Expires")); - time_t nickserv_expire = Config->GetModule("nickserv")->Get("expire", "90d"), - unconfirmed_expire = Config->GetModule("ns_register")->Get("unconfirmedexpire", "1d"); + time_t nickserv_expire = Config->GetModule("nickserv").Get("expire", "90d"), + unconfirmed_expire = Config->GetModule("ns_register").Get("unconfirmedexpire", "1d"); for (auto *na2 : *nc->aliases) { Anope::string expires; @@ -398,7 +398,7 @@ public: NSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnsgroup(this), commandnsungroup(this), commandnsglist(this) { - if (Config->GetModule("nickserv")->Get("nonicknameownership")) + if (Config->GetModule("nickserv").Get("nonicknameownership")) throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; diff --git a/modules/nickserv/ns_identify.cpp b/modules/nickserv/ns_identify.cpp index c1f077ee5..44e6bb840 100644 --- a/modules/nickserv/ns_identify.cpp +++ b/modules/nickserv/ns_identify.cpp @@ -95,7 +95,7 @@ public: return; } - unsigned int maxlogins = Config->GetModule(this->owner)->Get("maxlogins"); + unsigned int maxlogins = Config->GetModule(this->owner).Get("maxlogins"); if (na && maxlogins && na->nc->users.size() >= maxlogins) { source.Reply(_("Account \002%s\002 has already reached the maximum number of simultaneous logins (%u)."), na->nc->display.c_str(), maxlogins); diff --git a/modules/nickserv/ns_list.cpp b/modules/nickserv/ns_list.cpp index c322d259b..5a5beacbd 100644 --- a/modules/nickserv/ns_list.cpp +++ b/modules/nickserv/ns_list.cpp @@ -30,7 +30,7 @@ public: bool is_servadmin = source.HasCommand("nickserv/list"); int count = 0, from = 0, to = 0; bool suspended, nsnoexpire, unconfirmed; - unsigned listmax = Config->GetModule(this->owner)->Get("listmax", "50"); + unsigned listmax = Config->GetModule(this->owner).Get("listmax", "50"); suspended = nsnoexpire = unconfirmed = false; @@ -164,7 +164,7 @@ public: " \002LIST #51-100\002\n" " Lists all registered nicks within the given range (51-100).")); - const Anope::string ®exengine = Config->GetBlock("options")->Get("regexengine"); + const Anope::string ®exengine = Config->GetBlock("options").Get("regexengine"); if (!regexengine.empty()) { source.Reply(" "); diff --git a/modules/nickserv/ns_maxemail.cpp b/modules/nickserv/ns_maxemail.cpp index 45409188d..ab18e4b54 100644 --- a/modules/nickserv/ns_maxemail.cpp +++ b/modules/nickserv/ns_maxemail.cpp @@ -38,7 +38,7 @@ class NSMaxEmail final bool CheckLimitReached(CommandSource &source, const Anope::string &email) { - int NSEmailMax = Config->GetModule(this)->Get("maxemails"); + int NSEmailMax = Config->GetModule(this).Get("maxemails"); if (NSEmailMax < 1 || email.empty()) return false; @@ -79,9 +79,9 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - clean = conf->GetModule(this)->Get("remove_aliases", "true"); + clean = conf.GetModule(this).Get("remove_aliases", "true"); } EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector ¶ms) override diff --git a/modules/nickserv/ns_recover.cpp b/modules/nickserv/ns_recover.cpp index 8de4a9e40..062eb1dfc 100644 --- a/modules/nickserv/ns_recover.cpp +++ b/modules/nickserv/ns_recover.cpp @@ -71,7 +71,7 @@ public: Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << u->Account()->display; } - if (Config->GetModule("ns_recover")->Get("restoreonrecover")) + if (Config->GetModule("ns_recover").Get("restoreonrecover")) { if (!u->chans.empty()) { @@ -239,14 +239,14 @@ public: commandnsrecover(this), recover(this, "recover"), svsnick(this, "svsnick") { - if (Config->GetModule("nickserv")->Get("nonicknameownership")) + if (Config->GetModule("nickserv").Get("nonicknameownership")) throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } void OnUserNickChange(User *u, const Anope::string &oldnick) override { - if (Config->GetModule(this)->Get("restoreonrecover")) + if (Config->GetModule(this).Get("restoreonrecover")) { NSRecoverInfo *ei = recover.Get(u); BotInfo *NickServ = Config->GetClient("NickServ"); @@ -281,7 +281,7 @@ public: void OnJoinChannel(User *u, Channel *c) override { - if (Config->GetModule(this)->Get("restoreonrecover")) + if (Config->GetModule(this).Get("restoreonrecover")) { NSRecoverInfo *ei = recover.Get(u); diff --git a/modules/nickserv/ns_register.cpp b/modules/nickserv/ns_register.cpp index 38fa55ca5..8222f7ad3 100644 --- a/modules/nickserv/ns_register.cpp +++ b/modules/nickserv/ns_register.cpp @@ -56,7 +56,7 @@ public: NickAlias *u_na = NickAlias::Find(u->nick); /* Set +r if they're on a nick in the group */ - if (!Config->GetModule("nickserv")->Get("nonicknameownership") && u_na && *u_na->nc == *na->nc) + if (!Config->GetModule("nickserv").Get("nonicknameownership") && u_na && *u_na->nc == *na->nc) u->SetMode(source.service, "REGISTERED"); } } @@ -79,7 +79,7 @@ public: if (na) { IRCD->SendLogin(source.GetUser(), na); - if (!Config->GetModule("nickserv")->Get("nonicknameownership") && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED")) + if (!Config->GetModule("nickserv").Get("nonicknameownership") && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED")) source.GetUser()->SetMode(source.service, "REGISTERED"); } } @@ -124,7 +124,7 @@ public: CommandNSRegister(Module *creator) : Command(creator, "nickserv/register", 1, 2) { this->SetDesc(_("Register a nickname")); - if (Config->GetModule("nickserv")->Get("forceemail", "yes")) + if (Config->GetModule("nickserv").Get("forceemail", "yes")) this->SetSyntax(_("\037password\037 \037email\037")); else this->SetSyntax(_("\037password\037 \037[email]\037")); @@ -137,7 +137,7 @@ public: Anope::string u_nick = source.GetNick(); Anope::string pass = params[0]; Anope::string email = params.size() > 1 ? params[1] : ""; - const Anope::string &nsregister = Config->GetModule(this->owner)->Get("registration"); + const Anope::string &nsregister = Config->GetModule(this->owner).Get("registration"); if (Anope::ReadOnly) { @@ -151,8 +151,8 @@ public: return; } - time_t nickregdelay = Config->GetModule(this->owner)->Get("nickregdelay"); - time_t reg_delay = Config->GetModule("nickserv")->Get("regdelay"); + time_t nickregdelay = Config->GetModule(this->owner).Get("nickregdelay"); + time_t reg_delay = Config->GetModule("nickserv").Get("regdelay"); if (u && !u->HasMode("OPER") && nickregdelay && Anope::CurTime - u->timestamp < nickregdelay) { auto waitperiod = (u->timestamp + nickregdelay) - Anope::CurTime; @@ -179,7 +179,7 @@ public: return; } - if (Config->GetModule("nickserv")->Get("restrictopernicks")) + if (Config->GetModule("nickserv").Get("restrictopernicks")) { for (auto *o : Oper::opers) { @@ -191,10 +191,10 @@ public: } } - unsigned int minpasslen = Config->GetModule("nickserv")->Get("minpasslen", "10"); - unsigned int maxpasslen = Config->GetModule("nickserv")->Get("maxpasslen", "50"); + unsigned int minpasslen = Config->GetModule("nickserv").Get("minpasslen", "10"); + unsigned int maxpasslen = Config->GetModule("nickserv").Get("maxpasslen", "50"); - if (Config->GetModule("nickserv")->Get("forceemail", "yes") && email.empty()) + if (Config->GetModule("nickserv").Get("forceemail", "yes") && email.empty()) this->OnSyntaxError(source, ""); else if (u && Anope::CurTime < u->lastnickreg + reg_delay) { @@ -271,7 +271,7 @@ public: bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { - unsigned int minpasslen = Config->GetModule("nickserv")->Get("minpasslen", "10"); + unsigned int minpasslen = Config->GetModule("nickserv").Get("minpasslen", "10"); this->SendSyntax(source); source.Reply(" "); source.Reply(_("Registers your nickname in the %s database. Once\n" @@ -294,7 +294,7 @@ public: source.service->nick.c_str(), source.service->nick.c_str(), minpasslen); - if (!Config->GetModule("nickserv")->Get("forceemail", "yes")) + if (!Config->GetModule("nickserv").Get("forceemail", "yes")) { source.Reply(" "); source.Reply(_("The \037email\037 parameter is optional and will set the email\n" @@ -322,7 +322,7 @@ public: void Execute(CommandSource &source, const std::vector ¶ms) override { - if (!Config->GetModule(this->owner)->Get("registration").equals_ci("mail")) + if (!Config->GetModule(this->owner).Get("registration").equals_ci("mail")) { source.Reply(ACCESS_DENIED); return; @@ -336,7 +336,7 @@ public: source.Reply(_("Your account is already confirmed.")); else { - if (Anope::CurTime < source.nc->lastmail + Config->GetModule(this->owner)->Get("resenddelay")) + if (Anope::CurTime < source.nc->lastmail + Config->GetModule(this->owner).Get("resenddelay")) source.Reply(_("Cannot send mail now; please retry a little later.")); else if (SendRegmail(source.GetUser(), na, source.service)) { @@ -353,7 +353,7 @@ public: bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { - if (!Config->GetModule(this->owner)->Get("registration").equals_ci("mail")) + if (!Config->GetModule(this->owner).Get("registration").equals_ci("mail")) return false; this->SendSyntax(source); @@ -364,7 +364,7 @@ public: void OnServHelp(CommandSource &source) override { - if (Config->GetModule(this->owner)->Get("registration").equals_ci("mail")) + if (Config->GetModule(this->owner).Get("registration").equals_ci("mail")) Command::OnServHelp(source); } }; @@ -384,7 +384,7 @@ public: commandnsregister(this), commandnsconfirm(this), commandnsrsend(this), unconfirmed(this, "UNCONFIRMED"), passcode(this, "passcode") { - if (Config->GetModule(this)->Get("registration").equals_ci("disable")) + if (Config->GetModule(this).Get("registration").equals_ci("disable")) throw ModuleException("Module " + this->name + " will not load with registration disabled."); } @@ -393,14 +393,14 @@ public: BotInfo *NickServ; if (unconfirmed.HasExt(u->Account()) && (NickServ = Config->GetClient("NickServ"))) { - const Anope::string &nsregister = Config->GetModule(this)->Get("registration"); + const Anope::string &nsregister = Config->GetModule(this).Get("registration"); if (nsregister.equals_ci("admin")) u->SendMessage(NickServ, _("All new accounts must be validated by an administrator. Please wait for your registration to be confirmed.")); else u->SendMessage(NickServ, _("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you.")); const NickAlias *this_na = u->AccountNick(); time_t time_registered = Anope::CurTime - this_na->time_registered; - time_t unconfirmed_expire = Config->GetModule(this)->Get("unconfirmedexpire", "1d"); + time_t unconfirmed_expire = Config->GetModule(this).Get("unconfirmedexpire", "1d"); if (unconfirmed_expire > time_registered) u->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s."), Anope::Duration(unconfirmed_expire - time_registered, u->Account()).c_str()); } @@ -410,7 +410,7 @@ public: { if (unconfirmed.HasExt(na->nc)) { - time_t unconfirmed_expire = Config->GetModule(this)->Get("unconfirmedexpire", "1d"); + time_t unconfirmed_expire = Config->GetModule(this).Get("unconfirmedexpire", "1d"); if (unconfirmed_expire && Anope::CurTime - na->time_registered >= unconfirmed_expire) expire = true; } @@ -428,15 +428,15 @@ static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi) *code = Anope::Random(15); } - Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get("registration_subject").c_str()), - message = Language::Translate(na->nc, Config->GetBlock("mail")->Get("registration_message").c_str()); + Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail").Get("registration_subject").c_str()), + message = Language::Translate(na->nc, Config->GetBlock("mail").Get("registration_message").c_str()); subject = subject.replace_all_cs("%n", na->nick); - subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); subject = subject.replace_all_cs("%c", *code); message = message.replace_all_cs("%n", na->nick); - message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + message = message.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); message = message.replace_all_cs("%c", *code); return Mail::Send(u, nc, bi, subject, message); diff --git a/modules/nickserv/ns_resetpass.cpp b/modules/nickserv/ns_resetpass.cpp index fbb8d1540..52dd4e139 100644 --- a/modules/nickserv/ns_resetpass.cpp +++ b/modules/nickserv/ns_resetpass.cpp @@ -73,7 +73,7 @@ public: NSResetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnsresetpass(this), reset(this, "reset") { - if (!Config->GetBlock("mail")->Get("usemail")) + if (!Config->GetBlock("mail").Get("usemail")) throw ModuleException("Not using mail."); } @@ -132,16 +132,16 @@ public: static bool SendResetEmail(User *u, const NickAlias *na, BotInfo *bi) { - Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get("reset_subject").c_str()), - message = Language::Translate(na->nc, Config->GetBlock("mail")->Get("reset_message").c_str()), + Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail").Get("reset_subject").c_str()), + message = Language::Translate(na->nc, Config->GetBlock("mail").Get("reset_message").c_str()), passcode = Anope::Random(20); subject = subject.replace_all_cs("%n", na->nick); - subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); subject = subject.replace_all_cs("%c", passcode); message = message.replace_all_cs("%n", na->nick); - message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + message = message.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); message = message.replace_all_cs("%c", passcode); ResetInfo *ri = na->nc->Extend("reset"); diff --git a/modules/nickserv/ns_set.cpp b/modules/nickserv/ns_set.cpp index a1291fe26..b9d489ee3 100644 --- a/modules/nickserv/ns_set.cpp +++ b/modules/nickserv/ns_set.cpp @@ -34,8 +34,8 @@ public: source.Reply(_("Sets various nickname options. \037option\037 can be one of:")); Anope::string this_name = source.command; - bool hide_privileged_commands = Config->GetBlock("options")->Get("hideprivilegedcommands"), - hide_registered_commands = Config->GetBlock("options")->Get("hideregisteredcommands"); + bool hide_privileged_commands = Config->GetBlock("options").Get("hideprivilegedcommands"), + hide_registered_commands = Config->GetBlock("options").Get("hideregisteredcommands"); for (const auto &[c_name, info] : source.service->commands) { if (c_name.find_ci(this_name + " ") == 0) @@ -134,14 +134,14 @@ public: return; } - unsigned int minpasslen = Config->GetModule("nickserv")->Get("minpasslen", "10"); + unsigned int minpasslen = Config->GetModule("nickserv").Get("minpasslen", "10"); if (len < minpasslen) { source.Reply(PASSWORD_TOO_SHORT, minpasslen); return; } - unsigned int maxpasslen = Config->GetModule("nickserv")->Get("maxpasslen", "50"); + unsigned int maxpasslen = Config->GetModule("nickserv").Get("maxpasslen", "50"); if (len > maxpasslen) { source.Reply(PASSWORD_TOO_LONG, maxpasslen); @@ -196,7 +196,7 @@ public: size_t len = params[1].length(); - if (Config->GetModule("nickserv")->Get("secureadmins", "yes") && source.nc != nc && nc->IsServicesOper()) + if (Config->GetModule("nickserv").Get("secureadmins", "yes") && source.nc != nc && nc->IsServicesOper()) { source.Reply(_("You may not change the password of other Services Operators.")); return; @@ -208,14 +208,14 @@ public: return; } - unsigned int minpasslen = Config->GetModule("nickserv")->Get("minpasslen", "10"); + unsigned int minpasslen = Config->GetModule("nickserv").Get("minpasslen", "10"); if (len < minpasslen) { source.Reply(PASSWORD_TOO_SHORT, minpasslen); return; } - unsigned int maxpasslen = Config->GetModule("nickserv")->Get("maxpasslen", "50"); + unsigned int maxpasslen = Config->GetModule("nickserv").Get("maxpasslen", "50"); if (len > maxpasslen) { source.Reply(PASSWORD_TOO_LONG, maxpasslen); @@ -440,7 +440,7 @@ public: NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); - if (Config->GetModule("nickserv")->Get("nonicknameownership")) + if (Config->GetModule("nickserv").Get("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); return; @@ -526,19 +526,19 @@ class CommandNSSetEmail n->first = new_email; n->second = code; - Anope::string subject = Config->GetBlock("mail")->Get("emailchange_subject"), - message = Config->GetBlock("mail")->Get("emailchange_message"); + Anope::string subject = Config->GetBlock("mail").Get("emailchange_subject"), + message = Config->GetBlock("mail").Get("emailchange_message"); subject = subject.replace_all_cs("%e", nc->email); subject = subject.replace_all_cs("%E", new_email); subject = subject.replace_all_cs("%n", nc->display); - subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); subject = subject.replace_all_cs("%c", code); message = message.replace_all_cs("%e", nc->email); message = message.replace_all_cs("%E", new_email); message = message.replace_all_cs("%n", nc->display); - message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get("networkname")); + message = message.replace_all_cs("%N", Config->GetBlock("networkinfo").Get("networkname")); message = message.replace_all_cs("%c", code); Anope::string old = nc->email; @@ -577,12 +577,12 @@ public: return; } - if (param.empty() && Config->GetModule("nickserv")->Get("forceemail", "yes")) + if (param.empty() && Config->GetModule("nickserv").Get("forceemail", "yes")) { source.Reply(_("You cannot unset the email on this network.")); return; } - else if (Config->GetModule("nickserv")->Get("secureadmins", "yes") && source.nc != nc && nc->IsServicesOper()) + else if (Config->GetModule("nickserv").Get("secureadmins", "yes") && source.nc != nc && nc->IsServicesOper()) { source.Reply(_("You may not change the email of other Services Operators.")); return; @@ -598,8 +598,8 @@ public: if (MOD_RESULT == EVENT_STOP) return; - const auto nsmailreg = Config->GetModule("ns_register")->Get("registration").equals_ci("mail"); - if (!param.empty() && Config->GetModule("nickserv")->Get("confirmemailchanges", nsmailreg ? "yes" : "no") && !source.IsServicesOper()) + const auto nsmailreg = Config->GetModule("ns_register").Get("registration").equals_ci("mail"); + if (!param.empty() && Config->GetModule("nickserv").Get("confirmemailchanges", nsmailreg ? "yes" : "no") && !source.IsServicesOper()) { if (SendConfirmMail(source.GetUser(), source.GetAccount(), source.service, param)) { diff --git a/modules/nickserv/ns_set_keepmodes.cpp b/modules/nickserv/ns_set_keepmodes.cpp index e31b33dac..aa09d0555 100644 --- a/modules/nickserv/ns_set_keepmodes.cpp +++ b/modules/nickserv/ns_set_keepmodes.cpp @@ -191,7 +191,7 @@ public: { if (keep_modes.HasExt(u->Account())) { - const auto norestore = Config->GetModule(this)->Get("norestore"); + const auto norestore = Config->GetModule(this).Get("norestore"); User::ModeList modes = u->Account()->last_modes; for (const auto &[last_mode, last_value] : modes) { diff --git a/modules/nickserv/ns_set_kill.cpp b/modules/nickserv/ns_set_kill.cpp index 8447bf74f..0338c4bb8 100644 --- a/modules/nickserv/ns_set_kill.cpp +++ b/modules/nickserv/ns_set_kill.cpp @@ -30,7 +30,7 @@ public: return; } - if (Config->GetModule("nickserv")->Get("nonicknameownership")) + if (Config->GetModule("nickserv").Get("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); return; @@ -67,7 +67,7 @@ public: } else if (param.equals_ci("IMMED")) { - if (Config->GetModule(this->owner)->Get("allowkillimmed")) + if (Config->GetModule(this->owner).Get("allowkillimmed")) { nc->Extend("KILLPROTECT"); nc->Shrink("KILL_QUICK"); diff --git a/modules/nickserv/ns_set_misc.cpp b/modules/nickserv/ns_set_misc.cpp index 173f1f2da..77dd62d92 100644 --- a/modules/nickserv/ns_set_misc.cpp +++ b/modules/nickserv/ns_set_misc.cpp @@ -200,21 +200,21 @@ public: delete data; } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { descriptions.clear(); - for (int i = 0; i < conf->CountBlock("command"); ++i) + for (int i = 0; i < conf.CountBlock("command"); ++i) { - Configuration::Block *block = conf->GetBlock("command", i); + Configuration::Block &block = conf.GetBlock("command", i); - const Anope::string &cmd = block->Get("command"); + const Anope::string &cmd = block.Get("command"); if (cmd != "nickserv/set/misc" && cmd != "nickserv/saset/misc") continue; - Anope::string cname = block->Get("name"); - Anope::string desc = block->Get("misc_description"); + Anope::string cname = block.Get("name"); + Anope::string desc = block.Get("misc_description"); if (cname.empty() || desc.empty()) continue; diff --git a/modules/nickserv/ns_suspend.cpp b/modules/nickserv/ns_suspend.cpp index 6cdce688a..950528e50 100644 --- a/modules/nickserv/ns_suspend.cpp +++ b/modules/nickserv/ns_suspend.cpp @@ -70,7 +70,7 @@ public: const Anope::string &nick = params[0]; Anope::string expiry = params[1]; Anope::string reason = params.size() > 2 ? params[2] : ""; - time_t expiry_secs = Config->GetModule(this->owner)->Get("suspendexpire"); + time_t expiry_secs = Config->GetModule(this->owner).Get("suspendexpire"); if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); @@ -98,7 +98,7 @@ public: return; } - if (Config->GetModule("nickserv")->Get("secureadmins", "yes") && na->nc->IsServicesOper()) + if (Config->GetModule("nickserv").Get("secureadmins", "yes") && na->nc->IsServicesOper()) { source.Reply(_("You may not suspend other Services Operators' nicknames.")); return; @@ -240,9 +240,9 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - Anope::string s = conf->GetModule(this)->Get("show"); + Anope::string s = conf.GetModule(this).Get("show"); commasepstream(s).GetTokens(show); std::transform(show.begin(), show.end(), show.begin(), trim()); } -- cgit