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/botserv/botserv.cpp | 30 +++++++++++++++--------------- modules/botserv/bs_autoassign.cpp | 2 +- modules/botserv/bs_badwords.cpp | 4 ++-- modules/botserv/bs_kick.cpp | 10 +++++----- modules/botserv/bs_set.cpp | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) (limited to 'modules/botserv') diff --git a/modules/botserv/botserv.cpp b/modules/botserv/botserv.cpp index 0646668be..e77ffe46c 100644 --- a/modules/botserv/botserv.cpp +++ b/modules/botserv/botserv.cpp @@ -23,9 +23,9 @@ public: { } - void OnReload(Configuration::Conf *conf) override + void OnReload(Configuration::Conf &conf) override { - const Anope::string &bsnick = conf->GetModule(this)->Get("client"); + const Anope::string &bsnick = conf.GetModule(this).Get("client"); BotServ = BotInfo::Find(bsnick, true); } @@ -34,7 +34,7 @@ public: /* Do not allow removing bot modes on our service bots */ if (chan->ci && chan->ci->bi == user) { - const Anope::string &botmodes = Config->GetModule(this)->Get("botmodes"); + const Anope::string &botmodes = Config->GetModule(this).Get("botmodes"); for (auto botmode : botmodes) chan->SetMode(chan->ci->bi, ModeManager::FindChannelModeByChar(botmode), chan->ci->bi->GetUID()); } @@ -42,9 +42,9 @@ public: void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) override { - if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get("minusers")) + if (ci->c && ci->c->users.size() >= Config->GetModule(this).Get("minusers")) { - ChannelStatus status(Config->GetModule(this)->Get("botmodes")); + ChannelStatus status(Config->GetModule(this).Get("botmodes")); bi->Join(ci->c, &status); } } @@ -55,7 +55,7 @@ public: return; BotInfo *bi = user->server == Me ? dynamic_cast(user) : NULL; - if (bi && Config->GetModule(this)->Get("smartjoin")) + if (bi && Config->GetModule(this).Get("smartjoin")) { if (IRCD->CanClearBans) { @@ -99,9 +99,9 @@ public: * legit users - Rob **/ /* This is before the user has joined the channel, so check usercount + 1 */ - if (c->users.size() + 1 >= Config->GetModule(this)->Get("minusers") && !c->FindUser(c->ci->bi)) + if (c->users.size() + 1 >= Config->GetModule(this).Get("minusers") && !c->FindUser(c->ci->bi)) { - ChannelStatus status(Config->GetModule(this)->Get("botmodes")); + ChannelStatus status(Config->GetModule(this).Get("botmodes")); c->ci->bi->Join(c, &status); } } @@ -124,7 +124,7 @@ public: return; /* This is called prior to removing the user from the channel, so c->users.size() - 1 should be safe */ - if (c->ci && c->ci->bi && u != *c->ci->bi && c->users.size() - 1 <= Config->GetModule(this)->Get("minusers") && c->FindUser(c->ci->bi)) + if (c->ci && c->ci->bi && u != *c->ci->bi && c->users.size() - 1 <= Config->GetModule(this).Get("minusers") && c->FindUser(c->ci->bi)) c->ci->bi->Part(c->ci->c); } @@ -140,7 +140,7 @@ public: "channel, and provide a more convenient way to execute commands. Commands that\n" "require a channel as a parameter will automatically have that parameter\n" "given.\n"), source.service->nick.c_str()); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get("fantasycharacter", "!"); + const Anope::string &fantasycharacters = Config->GetModule("fantasy").Get("fantasycharacter", "!"); if (!fantasycharacters.empty()) source.Reply(_(" \n" "Fantasy commands may be prefixed with one of the following characters: %s\n"), fantasycharacters.c_str()); @@ -170,8 +170,8 @@ public: source.Reply(_(" \n" "Bot will join a channel whenever there is at least\n" - "\002%d\002 user(s) on it."), Config->GetModule(this)->Get("minusers")); - const Anope::string &fantasycharacters = Config->GetModule("fantasy")->Get("fantasycharacter", "!"); + "\002%d\002 user(s) on it."), Config->GetModule(this).Get("minusers")); + const Anope::string &fantasycharacters = Config->GetModule("fantasy").Get("fantasycharacter", "!"); if (!fantasycharacters.empty()) source.Reply(_("Additionally, if fantasy is enabled fantasy commands\n" "can be executed by prefixing the command name with\n" @@ -180,7 +180,7 @@ public: EventReturn OnChannelModeSet(Channel *c, MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { - if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) + if (source.GetUser() && !source.GetBot() && Config->GetModule(this).Get("smartjoin") && mode->name == "BAN" && c->ci && c->ci->bi && c->FindUser(c->ci->bi)) { BotInfo *bi = c->ci->bi; @@ -195,7 +195,7 @@ public: void OnCreateChan(ChannelInfo *ci) override { /* Set default bot flags */ - spacesepstream sep(Config->GetModule(this)->Get("defaults", "greet fantasy")); + spacesepstream sep(Config->GetModule(this).Get("defaults", "greet fantasy")); for (Anope::string token; sep.GetToken(token);) ci->Extend("BS_" + token.upper()); } @@ -211,7 +211,7 @@ public: void OnCreateBot(BotInfo *bi) override { if (bi->botmodes.empty()) - bi->botmodes = Config->GetModule(this)->Get("botumodes"); + bi->botmodes = Config->GetModule(this).Get("botumodes"); } }; diff --git a/modules/botserv/bs_autoassign.cpp b/modules/botserv/bs_autoassign.cpp index e988540fe..5292f8642 100644 --- a/modules/botserv/bs_autoassign.cpp +++ b/modules/botserv/bs_autoassign.cpp @@ -19,7 +19,7 @@ public: void OnChanRegistered(ChannelInfo *ci) override { - const Anope::string &bot = Config->GetModule(this)->Get("bot"); + const Anope::string &bot = Config->GetModule(this).Get("bot"); if (bot.empty()) return; diff --git a/modules/botserv/bs_badwords.cpp b/modules/botserv/bs_badwords.cpp index 5301fd042..95f749488 100644 --- a/modules/botserv/bs_badwords.cpp +++ b/modules/botserv/bs_badwords.cpp @@ -286,14 +286,14 @@ private: realword = word.substr(0, pos); } - unsigned badwordsmax = Config->GetModule(this->module)->Get("badwordsmax"); + unsigned badwordsmax = Config->GetModule(this->module).Get("badwordsmax"); if (badwords->GetBadWordCount() >= badwordsmax) { source.Reply(_("Sorry, you can only have %d bad words entries on a channel."), badwordsmax); return; } - bool casesensitive = Config->GetModule(this->module)->Get("casesensitive"); + bool casesensitive = Config->GetModule(this->module).Get("casesensitive"); for (unsigned i = 0, end = badwords->GetBadWordCount(); i < end; ++i) { diff --git a/modules/botserv/bs_kick.cpp b/modules/botserv/bs_kick.cpp index caaa51b01..eba2868a6 100644 --- a/modules/botserv/bs_kick.cpp +++ b/modules/botserv/bs_kick.cpp @@ -515,8 +515,8 @@ public: if (kd->floodsecs < 1) kd->floodsecs = 10; - if (kd->floodsecs > Config->GetModule(me)->Get("keepdata")) - kd->floodsecs = Config->GetModule(me)->Get("keepdata"); + if (kd->floodsecs > Config->GetModule(me).Get("keepdata")) + kd->floodsecs = Config->GetModule(me).Get("keepdata"); kd->flood = true; if (kd->ttb[TTB_FLOOD]) @@ -913,7 +913,7 @@ public: void purge() { - time_t keepdata = Config->GetModule(me)->Get("keepdata"); + time_t keepdata = Config->GetModule(me).Get("keepdata"); for (data_type::iterator it = data_map.begin(), it_end = data_map.end(); it != it_end;) { const Anope::string &user = it->first; @@ -1299,7 +1299,7 @@ public: /* Normalize the buffer */ Anope::string nbuf = Anope::NormalizeBuffer(realbuf); - bool casesensitive = Config->GetModule("botserv")->Get("casesensitive"); + bool casesensitive = Config->GetModule("botserv").Get("casesensitive"); /* Normalize can return an empty string if this only contains control codes etc */ if (badwords && !nbuf.empty()) @@ -1368,7 +1368,7 @@ public: if (mustkick) { check_ban(ci, u, kd, TTB_BADWORDS); - if (Config->GetModule(me)->Get("gentlebadwordreason")) + if (Config->GetModule(me).Get("gentlebadwordreason")) bot_kick(ci, u, _("Watch your language!")); else bot_kick(ci, u, _("Don't use the word \"%s\" on this channel!"), bw->word.c_str()); diff --git a/modules/botserv/bs_set.cpp b/modules/botserv/bs_set.cpp index 1ab00205d..9b536e19a 100644 --- a/modules/botserv/bs_set.cpp +++ b/modules/botserv/bs_set.cpp @@ -33,8 +33,8 @@ public: source.Reply(_("Configures bot options.\n" " \n" "Available options:")); - 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"); Anope::string this_name = source.command; for (const auto &[c_name, info] : source.service->commands) { -- cgit