diff options
| author | 2023-01-23 07:42:07 +0000 | |
|---|---|---|
| committer | 2023-01-23 13:07:53 +0000 | |
| commit | 5c4badf8ea3ba775854f0d26d3f2e0e119584faa (patch) | |
| tree | 05dd2c5c545f12f71866be6422146477ddd30e3f /src/modules | |
| parent | Vendor the fmtlib library. (diff) | |
Replace InspIRCd::Format with fmt::format.
Diffstat (limited to 'src/modules')
66 files changed, 235 insertions, 224 deletions
diff --git a/src/modules/extra/m_geo_maxmind.cpp b/src/modules/extra/m_geo_maxmind.cpp index cb9fc4761..65fd1e703 100644 --- a/src/modules/extra/m_geo_maxmind.cpp +++ b/src/modules/extra/m_geo_maxmind.cpp @@ -180,8 +180,8 @@ public: MMDB_s mmdb; int result = MMDB_open(file.c_str(), MMDB_MODE_MMAP, &mmdb); if (result != MMDB_SUCCESS) - throw ModuleException(this, InspIRCd::Format("Unable to load the MaxMind database (%s): %s", - file.c_str(), MMDB_strerror(result))); + throw ModuleException(this, INSP_FORMAT("Unable to load the MaxMind database ({}): {}", + file, MMDB_strerror(result))); // Swap the new database with the old database. std::swap(mmdb, geoapi.mmdb); diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 0a711131e..e3989e842 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -28,6 +28,7 @@ /// $PackageInfo: require_system("debian") libldap2-dev /// $PackageInfo: require_system("ubuntu") libldap2-dev + #include "inspircd.h" #include "threadsocket.h" #include "modules/ldap.h" @@ -465,7 +466,7 @@ private: if (res != req->success) { - ldap_result->error = InspIRCd::Format("%s (%s)", ldap_err2string(res), req->info().c_str()); + ldap_result->error = INSP_FORMAT("{} ({})", ldap_err2string(res), req->info()); return; } diff --git a/src/modules/extra/m_log_json.cpp b/src/modules/extra/m_log_json.cpp index 567fa0ace..caa4add32 100644 --- a/src/modules/extra/m_log_json.cpp +++ b/src/modules/extra/m_log_json.cpp @@ -19,11 +19,11 @@ /// $CompilerFlags: find_compiler_flags("RapidJSON") -#include "inspircd.h" - #include <rapidjson/ostreamwrapper.h> #include <rapidjson/writer.h> +#include "inspircd.h" + class JSONMethod final : public Log::Method , public Timer @@ -106,7 +106,7 @@ public: fflush(file); if (ferror(file)) - throw CoreException(InspIRCd::Format("Unable to write to %s: %s", name.c_str(), strerror(errno))); + throw CoreException(INSP_FORMAT("Unable to write to {}: {}", name, strerror(errno))); } // RapidJSON API: Write a character to the file. @@ -141,8 +141,8 @@ public: auto* fh = fopen(fulltarget.c_str(), "a"); if (!fh) { - throw CoreException(InspIRCd::Format("Unable to open %s for JSON logger at %s: %s", - fulltarget.c_str(), tag->source.str().c_str(), strerror(errno))); + throw CoreException(INSP_FORMAT("Unable to open {} for JSON logger at {}: {}", + fulltarget, tag->source.str(), strerror(errno))); } const unsigned long flush = tag->getUInt("flush", 20, 1); diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index dca78a847..b676003a8 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -42,8 +42,8 @@ #include <mysql_version.h> #include "inspircd.h" -#include "threadsocket.h" #include "modules/sql.h" +#include "threadsocket.h" #ifdef _WIN32 # pragma comment(lib, "mysqlclient.lib") @@ -288,7 +288,7 @@ private: unsigned long escapedsize = mysql_escape_string(buffer.data(), in.c_str(), in.length()); if (escapedsize == static_cast<unsigned long>(-1)) { - SQL::Error err(SQL::QSEND_FAIL, InspIRCd::Format("%u: %s", mysql_errno(connection), mysql_error(connection))); + SQL::Error err(SQL::QSEND_FAIL, INSP_FORMAT("{}: {}", mysql_errno(connection), mysql_error(connection))); query->OnError(err); return false; } @@ -384,7 +384,7 @@ public: { /* XXX: See /usr/include/mysql/mysqld_error.h for a list of * possible error numbers and error messages */ - SQL::Error e(SQL::QREPLY_FAIL, InspIRCd::Format("%u: %s", mysql_errno(connection), mysql_error(connection))); + SQL::Error e(SQL::QREPLY_FAIL, INSP_FORMAT("{}: {}", mysql_errno(connection), mysql_error(connection))); return new MySQLresult(e); } } diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp index 7cc0deb41..6e6f96d7b 100644 --- a/src/modules/m_abbreviation.cpp +++ b/src/modules/m_abbreviation.cpp @@ -78,7 +78,7 @@ public: /* Ambiguous command, list the matches */ if (!matchlist.empty()) { - user->WriteNumeric(ERR_AMBIGUOUSCOMMAND, InspIRCd::Format("Ambiguous abbreviation, possible matches: %s%s", foundcommand.c_str(), matchlist.c_str())); + user->WriteNumeric(ERR_AMBIGUOUSCOMMAND, INSP_FORMAT("Ambiguous abbreviation, possible matches: {}{}", foundcommand, matchlist)); return MOD_RES_DENY; } diff --git a/src/modules/m_account.cpp b/src/modules/m_account.cpp index 369ca9efb..a9850ba51 100644 --- a/src/modules/m_account.cpp +++ b/src/modules/m_account.cpp @@ -75,7 +75,7 @@ public: else { // Logged in. - user->WriteNumeric(RPL_LOGGEDIN, user->GetFullHost(), value, InspIRCd::Format("You are now logged in as %s", value.c_str())); + user->WriteNumeric(RPL_LOGGEDIN, user->GetFullHost(), value, INSP_FORMAT("You are now logged in as {}", value)); } } diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index b7a4d4caa..874ae07d3 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -270,8 +270,8 @@ public: if (percent < config->percent) return MOD_RES_PASSTHRU; - const std::string message = InspIRCd::Format("Your message exceeded the %d%% upper case character threshold for %s", - config->percent, channel->name.c_str()); + const std::string message = INSP_FORMAT("Your message exceeded the {}% upper case character threshold for {}", + config->percent, channel->name); switch (config->method) { diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp index d730a5caa..2815728d3 100644 --- a/src/modules/m_autoop.cpp +++ b/src/modules/m_autoop.cpp @@ -63,7 +63,7 @@ public: if (change.adding && !mh) { - source->WriteNumeric(ERR_UNKNOWNMODE, mid, InspIRCd::Format("Cannot find prefix mode '%s' for autoop", mid.c_str())); + source->WriteNumeric(ERR_UNKNOWNMODE, mid, INSP_FORMAT("Cannot find prefix mode '{}' for autoop", mid)); return MOD_RES_DENY; } else if (!mh) @@ -75,8 +75,8 @@ public: if (mh->GetLevelRequired(change.adding) > mylevel) { - source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, InspIRCd::Format("You must be able to %s mode %c (%s) to %s an autoop containing it", - change.adding ? "set" : "unset", mh->GetModeChar(), mh->name.c_str(), change.adding ? "add" : "remove")); + source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, INSP_FORMAT("You must be able to {} mode {} ({}) to {} an autoop containing it", + change.adding ? "set" : "unset", mh->GetModeChar(), mh->name, change.adding ? "add" : "remove")); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index a20fbe26f..7a8e4e8c0 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -96,7 +96,8 @@ public: ListModeBase::ModeList* list = banlm->GetList(channel); if (list && change.adding && maxbans <= list->size()) { - source->WriteNumeric(ERR_BANLISTFULL, channel->name, banlm->GetModeChar(), InspIRCd::Format("Channel ban list for %s is full (maximum entries for this channel is %lu)", channel->name.c_str(), maxbans)); + source->WriteNumeric(ERR_BANLISTFULL, channel->name, banlm->GetModeChar(), INSP_FORMAT("Channel ban list for {} is full (maximum entries for this channel is {})", + channel->name, maxbans)); return false; } @@ -164,19 +165,19 @@ public: { if (!ServerInstance->Channels.IsChannel(mask[CHAN])) { - source->WriteNumeric(ERR_NOSUCHCHANNEL, channel->name, InspIRCd::Format("Invalid channel name in redirection (%s)", mask[CHAN].c_str())); + source->WriteNumeric(ERR_NOSUCHCHANNEL, channel->name, INSP_FORMAT("Invalid channel name in redirection ({})", mask[CHAN])); return false; } auto* c = ServerInstance->Channels.Find(mask[CHAN]); if (!c) { - source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str())); + source->WriteNumeric(690, INSP_FORMAT("Target channel {} must exist to be set as a redirect.", mask[CHAN])); return false; } else if (change.adding && c->GetPrefixValue(source) < OP_VALUE) { - source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", mask[CHAN].c_str())); + source->WriteNumeric(690, INSP_FORMAT("You must be opped on {} to set it as a redirect.", mask[CHAN])); return false; } diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 4b392ae93..516d1d513 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -284,7 +284,7 @@ public: callerid_data* dat = extInfo.Get(user, true); if (dat->accepting.size() >= maxaccepts) { - user->WriteNumeric(ERR_ACCEPTFULL, InspIRCd::Format("Accept list is full (limit is %lu)", maxaccepts)); + user->WriteNumeric(ERR_ACCEPTFULL, INSP_FORMAT("Accept list is full (limit is {})", maxaccepts)); return false; } if (!dat->accepting.insert(whotoadd).second) @@ -422,12 +422,14 @@ public: { time_t now = ServerInstance->Time(); /* +g and *not* accepted */ - user->WriteNumeric(ERR_TARGUMODEG, dest->nick, InspIRCd::Format("is in +%c mode (server-side ignore).", myumode.GetModeChar())); + user->WriteNumeric(ERR_TARGUMODEG, dest->nick, INSP_FORMAT("is in +{} mode (server-side ignore).", myumode.GetModeChar())); if (now > (dat->lastnotify + long(notify_cooldown))) { user->WriteNumeric(RPL_TARGNOTIFY, dest->nick, "has been informed that you messaged them."); - dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, InspIRCd::Format("%s@%s", user->ident.c_str(), user->GetDisplayedHost().c_str()), InspIRCd::Format("is messaging you, and you have user mode +%c set. Use /ACCEPT +%s to allow.", - myumode.GetModeChar(), user->nick.c_str())); + dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, + INSP_FORMAT("{}@{}", user->ident, user->GetDisplayedHost()), + INSP_FORMAT("is messaging you, and you have user mode +{} set. Use /ACCEPT +{} to allow.", myumode.GetModeChar(), user->nick) + ); dat->lastnotify = now; } return MOD_RES_DENY; diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index c797a13ce..74f884760 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -202,7 +202,7 @@ public: if (rl) { // Channel is banned. - user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is CBANed: %s", cname.c_str(), rl->reason.c_str())); + user->WriteNumeric(ERR_BADCHANNEL, cname, INSP_FORMAT("Channel {} is CBANed: {}", cname, rl->reason)); ServerInstance->SNO.WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)", user->nick.c_str(), cname.c_str(), rl->reason.c_str()); return MOD_RES_DENY; diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 759bc70de..722b90512 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -143,8 +143,10 @@ public: if (hidemask) user->WriteNumeric(Numerics::CannotSendTo(chan, "Your part message contained a banned phrase and was blocked.")); else - user->WriteNumeric(Numerics::CannotSendTo(chan, InspIRCd::Format("Your part message contained a banned phrase (%s) and was blocked.", - match->mask.c_str()))); + { + user->WriteNumeric(Numerics::CannotSendTo(chan, INSP_FORMAT("Your part message contained a banned phrase ({}) and was blocked.", + match->mask))); + } } ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) override @@ -165,8 +167,10 @@ public: if (hidemask) user->WriteNumeric(Numerics::CannotSendTo(chan, "Your message to this channel contained a banned phrase and was blocked.")); else - user->WriteNumeric(Numerics::CannotSendTo(chan, InspIRCd::Format("Your message to this channel contained a banned phrase (%s) and was blocked.", - match->mask.c_str()))); + { + user->WriteNumeric(Numerics::CannotSendTo(chan, INSP_FORMAT("Your message to this channel contained a banned phrase ({}) and was blocked.", + match->mask))); + } return MOD_RES_DENY; } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index bc7f1c253..110621510 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -243,9 +243,8 @@ public: * Unlike Asuka, I define a clone as coming from the same host. --w00t */ const UserManager::CloneCounts& clonecount = ServerInstance->Users.GetCloneCounts(u); - context.Write("member", InspIRCd::Format("%u %s%s (%s\x0F)", clonecount.global, - memb->GetAllPrefixChars().c_str(), u->GetFullHost().c_str(), - u->GetRealName().c_str())); + context.Write("member", INSP_FORMAT("{} {}{} ({}\x0F)", clonecount.global, memb->GetAllPrefixChars(), + u->GetFullHost(), u->GetRealName())); } for (auto* lm : ServerInstance->Modes.GetListModes()) @@ -285,9 +284,8 @@ public: if (!matches.empty()) { const std::string whatmatch = stdalgo::string::join(matches, ','); - context.Write("match", InspIRCd::Format("%ld %s %s %s %s %s %s :%s", ++x, whatmatch.c_str(), - u->nick.c_str(), u->ident.c_str(), u->GetRealHost().c_str(), u->GetDisplayedHost().c_str(), - u->GetIPString().c_str(), u->GetRealName().c_str())); + context.Write("match", INSP_FORMAT("{} {} {} {} {} {} {} :{}", ++x, whatmatch, u->nick, u->ident, + u->GetRealHost(), u->GetDisplayedHost(), u->GetIPString(), u->GetRealName())); matches.clear(); } } diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index b2a8b8b59..590bdb2d7 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -106,7 +106,7 @@ public: { // A hostname can not contain NUL, LF, CR, or SPACE. if (chr == 0x00 || chr == 0x0A || chr == 0x0D || chr == 0x20) - throw ModuleException(this, InspIRCd::Format("<hostname:charmap> can not contain character 0x%02X (%c)", chr, chr)); + throw ModuleException(this, INSP_FORMAT("<hostname:charmap> can not contain character 0x{:02X} ({})", chr, chr)); newhostmap.set(static_cast<unsigned char>(chr)); } std::swap(newhostmap, cmd.hostmap); diff --git a/src/modules/m_cloak.cpp b/src/modules/m_cloak.cpp index 8c02ffc1e..2949601c4 100644 --- a/src/modules/m_cloak.cpp +++ b/src/modules/m_cloak.cpp @@ -62,14 +62,14 @@ public: if (cloak.empty()) continue; - noterpl.SendIfCap(user, stdrplcap, this, "CLOAK_RESULT", parameters[0], cloak, InspIRCd::Format("Cloak #%zu for %s is %s (type: %s)", - ++count, parameters[0].c_str(), cloak.c_str(), cloakmethod->GetName())); + noterpl.SendIfCap(user, stdrplcap, this, "CLOAK_RESULT", parameters[0], cloak, INSP_FORMAT("Cloak #{} for {} is {} (method: {})", + ++count, parameters[0], cloak, cloakmethod->GetName())); } if (!count) { - failrpl.SendIfCap(user, stdrplcap, this, "UNABLE_TO_CLOAK", parameters[0], InspIRCd::Format("There are no methods available for cloaking %s", - parameters[0].c_str())); + failrpl.SendIfCap(user, stdrplcap, this, "UNABLE_TO_CLOAK", parameters[0], INSP_FORMAT("There are no methods available for cloaking {}", + parameters[0])); } return CmdResult::SUCCESS; diff --git a/src/modules/m_cloak_md5.cpp b/src/modules/m_cloak_md5.cpp index 36e1e34d0..dc6f33613 100644 --- a/src/modules/m_cloak_md5.cpp +++ b/src/modules/m_cloak_md5.cpp @@ -169,14 +169,15 @@ struct CloakInfo final { if (ip.family() == AF_INET6) { - rv.append(InspIRCd::Format(".%02x%02x.%02x%02x%s", + rv.append(INSP_FORMAT(".{:02x}{:02x}.{:02x}{:02x}{}", ip.in6.sin6_addr.s6_addr[2], ip.in6.sin6_addr.s6_addr[3], - ip.in6.sin6_addr.s6_addr[0], ip.in6.sin6_addr.s6_addr[1], suffix.c_str())); + ip.in6.sin6_addr.s6_addr[0], ip.in6.sin6_addr.s6_addr[1], + suffix)); } else { const unsigned char* ip4 = (const unsigned char*)&ip.in4.sin_addr; - rv.append(InspIRCd::Format(".%d.%d%s", ip4[1], ip4[0], suffix.c_str())); + rv.append(INSP_FORMAT(".{}.{}{}", ip4[1], ip4[0], suffix)); } } return rv; diff --git a/src/modules/m_cloak_sha256.cpp b/src/modules/m_cloak_sha256.cpp index 397b2f3bc..78deda345 100644 --- a/src/modules/m_cloak_sha256.cpp +++ b/src/modules/m_cloak_sha256.cpp @@ -109,11 +109,11 @@ private: unsigned int c = (unsigned int)(address >> 16) & 0xFF; unsigned int d = (unsigned int)(address >> 24) & 0xFF; - const std::string alpha = Hash(InspIRCd::Format("%u.%u.%u.%u", a, b, c, d)); - const std::string beta = Hash(InspIRCd::Format("%u.%u.%u", a, b, c)); - const std::string gamma = Hash(InspIRCd::Format("%u.%u", a, b)); + const std::string alpha = Hash(INSP_FORMAT("{}.{}.{}.{}", a, b, c, d)); + const std::string beta = Hash(INSP_FORMAT("{}.{}.{}", a, b, c)); + const std::string gamma = Hash(INSP_FORMAT("{}.{}", a, b)); - return Wrap(InspIRCd::Format("%s.%s.%s", alpha.c_str(), beta.c_str(), gamma.c_str()), suffix, '.'); + return Wrap(INSP_FORMAT("{}.{}.{}", alpha, beta, gamma), suffix, '.'); } std::string CloakIPv6(const unsigned char* address) @@ -133,11 +133,11 @@ private: unsigned int g = ntohs(address16[6]); unsigned int h = ntohs(address16[7]); - const std::string alpha = Hash(InspIRCd::Format("%x:%x:%x:%x:%x:%x:%x:%x", a, b, c, d, e, f, g, h)); - const std::string beta = Hash(InspIRCd::Format("%x:%x:%x:%x:%x:%x:%x", a, b, c, d, e, f, g)); - const std::string gamma = Hash(InspIRCd::Format("%x:%x:%x:%x", a, b, c, d)); + const std::string alpha = Hash(INSP_FORMAT("{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}", a, b, c, d, e, f, g, h)); + const std::string beta = Hash(INSP_FORMAT("{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}", a, b, c, d, e, f, g)); + const std::string gamma = Hash(INSP_FORMAT("{:x}:{:x}:{:x}:{:x}", a, b, c, d)); - return Wrap(InspIRCd::Format("%s:%s:%s", alpha.c_str(), beta.c_str(), gamma.c_str()), suffix, ':'); + return Wrap(INSP_FORMAT("{}:{}:{}", alpha, beta, gamma), suffix, ':'); } std::string CloakHost(const std::string& host, char separator, unsigned long parts) diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 83ae5a79d..245e86849 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -154,8 +154,7 @@ public: data["map"].push_back(','); } - compatdata = InspIRCd::Format("front=%s&middle=%s&map=%s", data["front"].c_str(), - data["middle"].c_str(), data["map"].c_str()); + compatdata = INSP_FORMAT("front={}&middle={}&map={}", data["front"], data["middle"], data["map"]); } bool Map(unsigned long upper, unsigned long lower) override @@ -285,12 +284,12 @@ public: break; case Codepage::AllowCharacterResult::NOT_VALID: - throw ModuleException(this, InspIRCd::Format("<cpchars> tag contains a forbidden character: %lu at %s", - pos, tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("<cpchars> tag contains a forbidden character: {} at {}", + pos, tag->source.str())); case Codepage::AllowCharacterResult::NOT_VALID_AT_FRONT: - throw ModuleException(this, InspIRCd::Format("<cpchars> tag contains a forbidden front character: %lu at %s", - pos, tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("<cpchars> tag contains a forbidden front character: {} at {}", + pos, tag->source.str())); } } } diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index b346c8641..b0dce6c2a 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -258,7 +258,7 @@ public: if (i->nickname == target->nick) { dl->erase(i); - user->WriteNumeric(RPL_DCCALLOWREMOVED, user->nick, InspIRCd::Format("Removed %s from your DCCALLOW list", target->nick.c_str())); + user->WriteNumeric(RPL_DCCALLOWREMOVED, user->nick, INSP_FORMAT("Removed {} from your DCCALLOW list", target->nick)); break; } } @@ -291,7 +291,7 @@ public: { if (dccallow.nickname == target->nick) { - user->WriteNumeric(ERR_DCCALLOWINVALID, user->nick, InspIRCd::Format("%s is already on your DCCALLOW list", target->nick.c_str())); + user->WriteNumeric(ERR_DCCALLOWINVALID, user->nick, INSP_FORMAT("{} is already on your DCCALLOW list", target->nick)); return CmdResult::FAILURE; } } @@ -304,7 +304,7 @@ public: } else if (!Duration::IsValid(parameters[1])) { - user->WriteNumeric(ERR_DCCALLOWINVALID, user->nick, InspIRCd::Format("%s is not a valid DCCALLOW duration", parameters[1].c_str())); + user->WriteNumeric(ERR_DCCALLOWINVALID, user->nick, INSP_FORMAT("{} is not a valid DCCALLOW duration", parameters[1])); return CmdResult::FAILURE; } else @@ -325,11 +325,11 @@ public: if (length > 0) { - user->WriteNumeric(RPL_DCCALLOWTIMED, user->nick, InspIRCd::Format("Added %s to DCCALLOW list for %s", target->nick.c_str(), Duration::ToString(length).c_str())); + user->WriteNumeric(RPL_DCCALLOWTIMED, user->nick, INSP_FORMAT("Added {} to DCCALLOW list for {}", target->nick, Duration::ToString(length))); } else { - user->WriteNumeric(RPL_DCCALLOWPERMANENT, user->nick, InspIRCd::Format("Added %s to DCCALLOW list for this session", target->nick.c_str())); + user->WriteNumeric(RPL_DCCALLOWPERMANENT, user->nick, INSP_FORMAT("Added {} to DCCALLOW list for this session", target->nick)); } /* route it. */ @@ -373,8 +373,8 @@ public: { for (const auto& dccallow : *dl) { - user->WriteNumeric(RPL_DCCALLOWLIST, user->nick, InspIRCd::Format("%s (%s)", - dccallow.nickname.c_str(), dccallow.hostmask.c_str())); + user->WriteNumeric(RPL_DCCALLOWLIST, user->nick, INSP_FORMAT("{} ({})", + dccallow.nickname, dccallow.hostmask)); } } @@ -539,7 +539,7 @@ public: time_t expires = iter2->set_on + iter2->length; if (iter2->length != 0 && expires <= ServerInstance->Time()) { - u->WriteNumeric(RPL_DCCALLOWEXPIRED, u->nick, InspIRCd::Format("DCCALLOW entry for %s has expired", iter2->nickname.c_str())); + u->WriteNumeric(RPL_DCCALLOWEXPIRED, u->nick, INSP_FORMAT("DCCALLOW entry for {} has expired", iter2->nickname)); iter2 = dl->erase(iter2); } else @@ -574,7 +574,7 @@ public: { u->WriteNotice(i->nickname + " left the network or changed their nickname and has been removed from your DCCALLOW list"); - u->WriteNumeric(RPL_DCCALLOWREMOVED, u->nick, InspIRCd::Format("Removed %s from your DCCALLOW list", i->nickname.c_str())); + u->WriteNumeric(RPL_DCCALLOWREMOVED, u->nick, INSP_FORMAT("Removed {} from your DCCALLOW list", i->nickname)); dl->erase(i); break; } diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index 25d744656..97c2f22e0 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -143,7 +143,7 @@ ModResult ModuleDelayMsg::HandleMessage(User* user, const MessageTarget& target, if (user->HasPrivPermission("channels/ignore-delaymsg")) return MOD_RES_PASSTHRU; - const std::string message = InspIRCd::Format("You cannot send messages to this channel until you have been a member for %ld seconds.", len); + const std::string message = INSP_FORMAT("You cannot send messages to this channel until you have been a member for {} seconds.", len); user->WriteNumeric(Numerics::CannotSendTo(channel, message)); return MOD_RES_DENY; } diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 7f64a3289..c1d1b4a54 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -171,14 +171,14 @@ public: if (badchan.redirect.empty() || user->IsModeSet(antiredirectmode) || ((target = ServerInstance->Channels.Find(badchan.redirect)) && target->IsModeSet(redirectmode))) { - user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is forbidden: %s", - cname.c_str(), badchan.reason.c_str())); + user->WriteNumeric(ERR_BADCHANNEL, cname, INSP_FORMAT("Channel {} is forbidden: {}", cname, + badchan.reason)); return MOD_RES_DENY; } // Redirect the user to the target channel. - user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is forbidden, redirecting to %s: %s", - cname.c_str(), badchan.redirect.c_str(), badchan.reason.c_str())); + user->WriteNumeric(ERR_BADCHANNEL, cname, INSP_FORMAT("Channel {} is forbidden, redirecting to {}: {}", + cname, badchan.redirect, badchan.reason)); Channel::JoinUser(user, badchan.redirect); return MOD_RES_DENY; } diff --git a/src/modules/m_disable.cpp b/src/modules/m_disable.cpp index a264642ec..b7bc31892 100644 --- a/src/modules/m_disable.cpp +++ b/src/modules/m_disable.cpp @@ -48,14 +48,14 @@ private: { // Check that the character is a valid mode letter. if (!ModeParser::IsModeChar(chr)) - throw ModuleException(this, InspIRCd::Format("Invalid mode '%c' was specified in <disabled:%s> at %s", - chr, field.c_str(), tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("Invalid mode '{}' was specified in <disabled:{}> at {}", + chr, field, tag->source.str())); // Check that the mode actually exists. ModeHandler* mh = ServerInstance->Modes.FindMode(chr, type); if (!mh) - throw ModuleException(this, InspIRCd::Format("Nonexistent mode '%c' was specified in <disabled:%s> at %s", - chr, field.c_str(), tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("Nonexistent mode '{}' was specified in <disabled:{}> at {}", + chr, field, tag->source.str())); // Disable the mode. ServerInstance->Logs.Debug(MODNAME, "The %c (%s) %s mode has been disabled", @@ -93,8 +93,8 @@ public: // Check that the command actually exists. Command* handler = ServerInstance->Parser.GetHandler(command); if (!handler) - throw ModuleException(this, InspIRCd::Format("Nonexistent command '%s' was specified in <disabled:commands> at %s", - command.c_str(), tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("Nonexistent command '{}' was specified in <disabled:commands> at {}", + command, tag->source.str())); // Prevent admins from disabling MODULES for transparency reasons. if (handler->name == "MODULES") @@ -190,13 +190,13 @@ public: // treated as if they do not exist. int numeric = (change.mh->GetModeType() == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK); const char* typestr = (change.mh->GetModeType() == MODETYPE_CHANNEL ? "channel" : "user"); - user->WriteNumeric(numeric, change.mh->GetModeChar(), InspIRCd::Format("is not a recognised %s mode.", typestr)); + user->WriteNumeric(numeric, change.mh->GetModeChar(), INSP_FORMAT("is not a recognised {} mode.", typestr)); return MOD_RES_DENY; } // Inform the user that the mode they changed has been disabled. - user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - %s mode %c (%s) is disabled", - what, change.mh->GetModeChar(), change.mh->name.c_str())); + user->WriteNumeric(ERR_NOPRIVILEGES, INSP_FORMAT("Permission Denied - {} mode {} ({}) is disabled", + what, change.mh->GetModeChar(), change.mh->name)); return MOD_RES_DENY; } }; diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index e7e16ba65..f28c277c6 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -572,8 +572,8 @@ public: total_misses += dnsbl->stats_misses; total_errors += dnsbl->stats_errors; - stats.AddGenericRow(InspIRCd::Format("The \"%s\" DNSBL had %lu hits, %lu misses, and %lu errors", - dnsbl->name.c_str(), dnsbl->stats_hits, dnsbl->stats_misses, dnsbl->stats_errors)); + stats.AddGenericRow(INSP_FORMAT("The \"{}\" DNSBL had {} hits, {} misses, and {} errors", + dnsbl->name, dnsbl->stats_hits, dnsbl->stats_misses, dnsbl->stats_errors)); } stats.AddGenericRow("Total DNSBL hits: " + ConvToStr(total_hits)); diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index c08144f91..6df211a55 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -76,8 +76,8 @@ public: if (channel->GetPrefixValue(source) >= pm->GetLevelRequired(change.adding)) return MOD_RES_PASSTHRU; - source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, InspIRCd::Format("You must be able to %s mode %c (%s) to %s a restriction containing it", - change.adding ? "set" : "unset", pm->GetModeChar(), pm->name.c_str(), change.adding ? "add" : "remove")); + source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, INSP_FORMAT("You must be able to {} mode {} ({}) to {} a restriction containing it", + change.adding ? "set" : "unset", pm->GetModeChar(), pm->name, change.adding ? "add" : "remove")); return MOD_RES_DENY; } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 70acc5099..4248b83f9 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -311,11 +311,9 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters) std::pair<bool, std::string> result = static_cast<ModuleFilter*>(me)->AddFilter(freeform, type, parameters[reasonindex], duration, flags); if (result.first) { - const std::string message = InspIRCd::Format("'%s', type '%s'%s, flags '%s', reason: %s", - freeform.c_str(), parameters[1].c_str(), - (duration ? InspIRCd::Format(", duration '%s'", - Duration::ToString(duration).c_str()).c_str() - : ""), flags.c_str(), parameters[reasonindex].c_str()); + const std::string message = INSP_FORMAT("'{}', type '{}'{}, flags '{}', reason: {}", freeform, parameters[1], + (duration ? INSP_FORMAT(", duration '{}'", Duration::ToString(duration)) : ""), + flags, parameters[reasonindex]); user->WriteNotice("*** Added filter " + message); ServerInstance->SNO.WriteToSnoMask(IS_LOCAL(user) ? 'f' : 'F', @@ -422,26 +420,26 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar if (is_selfmsg && warnonselfmsg) { - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("WARNING: %s's self message matched %s (%s)", - user->nick.c_str(), f->freeform.c_str(), f->reason.c_str())); + ServerInstance->SNO.WriteGlobalSno('f', "WARNING: %s's self message matched %s (%s)", + user->nick.c_str(), f->freeform.c_str(), f->reason.c_str()); return MOD_RES_PASSTHRU; } else if (f->action == FA_WARN) { - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("WARNING: %s's message to %s matched %s (%s)", - user->nick.c_str(), msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str())); + ServerInstance->SNO.WriteGlobalSno('f', "WARNING: %s's message to %s matched %s (%s)", + user->nick.c_str(), msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str()); return MOD_RES_PASSTHRU; } else if (f->action == FA_BLOCK) { - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s had their message to %s filtered as it matched %s (%s)", - user->nick.c_str(), msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str())); + ServerInstance->SNO.WriteGlobalSno('f', "%s had their message to %s filtered as it matched %s (%s)", + user->nick.c_str(), msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str()); if (notifyuser) { if (msgtarget.type == MessageTarget::TYPE_CHANNEL) - user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<Channel>(), InspIRCd::Format("Your message to this channel was blocked: %s.", f->reason.c_str()))); + user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<Channel>(), INSP_FORMAT("Your message to this channel was blocked: {}.", f->reason))); else - user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<User>(), InspIRCd::Format("Your message to this user was blocked: %s.", f->reason.c_str()))); + user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<User>(), INSP_FORMAT("Your message to this user was blocked: {}.", f->reason))); } else details.echo_original = true; @@ -451,26 +449,26 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar if (notifyuser) { if (msgtarget.type == MessageTarget::TYPE_CHANNEL) - user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<Channel>(), InspIRCd::Format("Your message to this channel was blocked: %s.", f->reason.c_str()))); + user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<Channel>(), INSP_FORMAT("Your message to this channel was blocked: {}.", f->reason))); else - user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<User>(), InspIRCd::Format("Your message to this user was blocked: %s.", f->reason.c_str()))); + user->WriteNumeric(Numerics::CannotSendTo(msgtarget.Get<User>(), INSP_FORMAT("Your message to this user was blocked: {}.", f->reason))); } else details.echo_original = true; } else if (f->action == FA_KILL) { - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s was killed because their message to %s matched %s (%s)", - user->nick.c_str(), msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str())); + ServerInstance->SNO.WriteGlobalSno('f', "%s was killed because their message to %s matched %s (%s)", + user->nick.c_str(), msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str()); ServerInstance->Users.QuitUser(user, "Filtered: " + f->reason); } else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN"))) { auto* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was shunned for %s (expires on %s) because their message to %s matched %s (%s)", + ServerInstance->SNO.WriteGlobalSno('f', "%s (%s) was shunned for %s (expires on %s) because their message to %s matched %s (%s)", user->nick.c_str(), sh->Displayable().c_str(), Duration::ToString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), - msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str())); + msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str()); if (ServerInstance->XLines->AddLine(sh, nullptr)) { ServerInstance->XLines->ApplyLines(); @@ -481,10 +479,10 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar else if (f->action == FA_GLINE) { auto* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was G-lined for %s (expires on %s) because their message to %s matched %s (%s)", + ServerInstance->SNO.WriteGlobalSno('f', "%s (%s) was G-lined for %s (expires on %s) because their message to %s matched %s (%s)", user->nick.c_str(), gl->Displayable().c_str(), Duration::ToString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), - msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str())); + msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str()); if (ServerInstance->XLines->AddLine(gl, nullptr)) { ServerInstance->XLines->ApplyLines(); @@ -495,10 +493,10 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar else if (f->action == FA_ZLINE) { auto* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was Z-lined for %s (expires on %s) because their message to %s matched %s (%s)", + ServerInstance->SNO.WriteGlobalSno('f', "%s (%s) was Z-lined for %s (expires on %s) because their message to %s matched %s (%s)", user->nick.c_str(), zl->Displayable().c_str(), Duration::ToString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), - msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str())); + msgtarget.GetName().c_str(), f->freeform.c_str(), f->reason.c_str()); if (ServerInstance->XLines->AddLine(zl, nullptr)) { ServerInstance->XLines->ApplyLines(); @@ -572,11 +570,11 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& { /* Note: We G-line *@IP so that if their host doesn't resolve the G-line still applies. */ auto* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was G-lined for %s (expires on %s) because their %s message matched %s (%s)", + ServerInstance->SNO.WriteGlobalSno('f', "%s (%s) was G-lined for %s (expires on %s) because their %s message matched %s (%s)", user->nick.c_str(), gl->Displayable().c_str(), Duration::ToString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), - command.c_str(), f->freeform.c_str(), f->reason.c_str())); + command.c_str(), f->freeform.c_str(), f->reason.c_str()); if (ServerInstance->XLines->AddLine(gl, nullptr)) { @@ -588,11 +586,11 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& if (f->action == FA_ZLINE) { auto* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was Z-lined for %s (expires on %s) because their %s message matched %s (%s)", + ServerInstance->SNO.WriteGlobalSno('f', "%s (%s) was Z-lined for %s (expires on %s) because their %s message matched %s (%s)", user->nick.c_str(), zl->Displayable().c_str(), Duration::ToString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), - command.c_str(), f->freeform.c_str(), f->reason.c_str())); + command.c_str(), f->freeform.c_str(), f->reason.c_str()); if (ServerInstance->XLines->AddLine(zl, nullptr)) { @@ -605,11 +603,11 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& { /* Note: We shun *!*@IP so that if their host doesnt resolve the shun still applies. */ auto* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); - ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was shunned for %s (expires on %s) because their %s message matched %s (%s)", + ServerInstance->SNO.WriteGlobalSno('f', "%s (%s) was shunned for %s (expires on %s) because their %s message matched %s (%s)", user->nick.c_str(), sh->Displayable().c_str(), Duration::ToString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), - command.c_str(), f->freeform.c_str(), f->reason.c_str())); + command.c_str(), f->freeform.c_str(), f->reason.c_str()); if (ServerInstance->XLines->AddLine(sh, nullptr)) { diff --git a/src/modules/m_gateway.cpp b/src/modules/m_gateway.cpp index a68ea5a07..bb6b23abe 100644 --- a/src/modules/m_gateway.cpp +++ b/src/modules/m_gateway.cpp @@ -150,21 +150,20 @@ public: } uint32_t addr = sa.in4.sin_addr.s_addr; - user->WriteNotice(InspIRCd::Format("*** HEXIP: %s encodes to %02x%02x%02x%02x.", - sa.addr().c_str(), (addr & 0xFF), ((addr >> 8) & 0xFF), ((addr >> 16) & 0xFF), + user->WriteNotice(INSP_FORMAT("*** HEXIP: {} encodes to {:02x}{:02x}{:02x}{:02x}.", + sa.addr(), (addr & 0xFF), ((addr >> 8) & 0xFF), ((addr >> 16) & 0xFF), ((addr >> 24) & 0xFF))); return CmdResult::SUCCESS; } if (ParseIP(parameters[0], sa)) { - user->WriteNotice(InspIRCd::Format("*** HEXIP: %s decodes to %s.", - parameters[0].c_str(), sa.addr().c_str())); + user->WriteNotice(INSP_FORMAT("*** HEXIP: {} decodes to {}.", parameters[0], sa.addr())); return CmdResult::SUCCESS; } - user->WriteNotice(InspIRCd::Format("*** HEXIP: %s is not a valid raw or hex encoded IPv4 address.", - parameters[0].c_str())); + user->WriteNotice(INSP_FORMAT("*** HEXIP: {} is not a valid raw or hex encoded IPv4 address.", + parameters[0])); return CmdResult::FAILURE; } diff --git a/src/modules/m_geoclass.cpp b/src/modules/m_geoclass.cpp index c57073cc5..386aa31c4 100644 --- a/src/modules/m_geoclass.cpp +++ b/src/modules/m_geoclass.cpp @@ -85,12 +85,12 @@ public: for (const auto& [location, count] : counts) { - stats.AddGenericRow(InspIRCd::Format("%s (%s): %lu", location->GetName().c_str(), - location->GetCode().c_str(), count)); + stats.AddGenericRow(INSP_FORMAT("{} ({}): {}", location->GetName(), + location->GetCode(), count)); } if (unknown) - stats.AddGenericRow("Unknown Country: " + ConvToStr(unknown)); + stats.AddGenericRow(INSP_FORMAT("Unknown Country: {}", unknown)); return MOD_RES_DENY; } diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index 861347fa3..5fe3026ca 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -121,16 +121,16 @@ public: // Attempt to read the help key. const std::string key = tag->getString("key"); if (key.empty()) - throw ModuleException(this, InspIRCd::Format("<helpop:key> is empty at %s", tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("<helpop:key> is empty at {}", tag->source.str())); else if (irc::equals(key, "index")) - throw ModuleException(this, InspIRCd::Format("<helpop:key> is set to \"index\" which is reserved at %s", tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("<helpop:key> is set to \"index\" which is reserved at {}", tag->source.str())); else if (key.length() > longestkey) longestkey = key.length(); // Attempt to read the help value. std::string value; if (!tag->readString("value", value, true) || value.empty()) - throw ModuleException(this, InspIRCd::Format("<helpop:value> is empty at %s", tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("<helpop:value> is empty at {}", tag->source.str())); // Parse the help body. Empty lines are replaced with a single // space because some clients are unable to show blank lines. @@ -140,11 +140,11 @@ public: helpmsg.push_back(line.empty() ? " " : line); // Read the help title and store the topic. - const std::string title = tag->getString("title", InspIRCd::Format("*** Help for %s", key.c_str()), 1); + const std::string title = tag->getString("title", INSP_FORMAT("*** Help for {}", key), 1); if (!newhelp.emplace(key, HelpTopic(helpmsg, title)).second) { - throw ModuleException(this, InspIRCd::Format("<helpop> tag with duplicate key '%s' at %s", - key.c_str(), tag->source.str().c_str())); + throw ModuleException(this, INSP_FORMAT("<helpop> tag with duplicate key '{}' at {}", + key, tag->source.str())); } } diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index 8dec3855d..ba3cc0ae1 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -50,7 +50,7 @@ public: if (user->HasPrivPermission("channels/auspex")) return true; - user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(chan, minrank, InspIRCd::Format("view the channel %s list", GetModeName().c_str()))); + user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(chan, minrank, INSP_FORMAT("view the channel {} list", GetModeName()))); return false; } }; diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index b0cc76005..6970ab2ce 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -161,8 +161,8 @@ public: { const std::string awayperiod = Duration::ToString(ServerInstance->Time() - oper->awaytime); const std::string awaytime = InspIRCd::TimeString(oper->awaytime); - extra += InspIRCd::Format(": away for %s [since %s] (%s)", awayperiod.c_str(), - awaytime.c_str(), oper->awaymsg.c_str()); + + extra = INSP_FORMAT(": away for {} [since {}] ({})", awayperiod, awaytime, oper->awaymsg); } auto* loper = IS_LOCAL(oper); @@ -170,14 +170,13 @@ public: { const std::string idleperiod = Duration::ToString(ServerInstance->Time() - loper->idle_lastmsg); const std::string idletime = InspIRCd::TimeString(loper->idle_lastmsg); - extra += InspIRCd::Format("%c idle for %s [since %s]", extra.empty() ? ':' : ',', - idleperiod.c_str(), idletime.c_str()); + + extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime); } - stats.AddGenericRow(InspIRCd::Format("\x02%s\x02 (%s)%s", oper->nick.c_str(), - oper->MakeHost().c_str(), extra.c_str())); + stats.AddGenericRow(INSP_FORMAT("\x02{}\x02 ({}){}", oper->nick, oper->MakeHost(), extra)); } - stats.AddGenericRow(InspIRCd::Format("%zu server operator%s total", opers, opers ? "s" : "")); + stats.AddGenericRow(INSP_FORMAT("{} server operator{} total", opers, opers ? "s" : "")); return MOD_RES_DENY; } }; diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 22df16eee..be2956c73 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -201,7 +201,7 @@ public: { // A hostname can not contain NUL, LF, CR, or SPACE. if (chr == 0x00 || chr == 0x0A || chr == 0x0D || chr == 0x20) - throw ModuleException(this, InspIRCd::Format("<hostname:charmap> can not contain character 0x%02X (%c)", chr, chr)); + throw ModuleException(this, INSP_FORMAT("<hostname:charmap> can not contain character 0x{:02X} ({})", chr, chr)); newhostmap.set(static_cast<unsigned char>(chr)); } std::swap(newhostmap, hostmap); diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 29c6ff41e..72af19738 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -256,9 +256,9 @@ public: ServerInstance->Logs.Debug(MODNAME, "Sending HTTP error %u: %s", response, errstr); static HTTPHeaders empty; - std::string data = InspIRCd::Format( + std::string data = INSP_FORMAT( "<html><head></head><body style='font-family: sans-serif; text-align: center'>" - "<h1 style='font-size: 48pt'>Error %u</h1><h2 style='font-size: 24pt'>%s</h2><hr>" + "<h1 style='font-size: 48pt'>Error {}</h1><h2 style='font-size: 24pt'>{}</h2><hr>" "<small>Powered by <a href='https://www.inspircd.org'>InspIRCd</a></small></body></html>", response, errstr); @@ -267,7 +267,7 @@ public: void SendHeaders(unsigned long size, unsigned int response, HTTPHeaders& rheaders) { - WriteData(InspIRCd::Format("HTTP/%u.%u %u %s\r\n", parser.http_major ? parser.http_major : 1, parser.http_major ? parser.http_minor : 1, response, http_status_str((http_status)response))); + WriteData(INSP_FORMAT("HTTP/{}.{} {} {}\r\n", parser.http_major ? parser.http_major : 1, parser.http_major ? parser.http_minor : 1, response, http_status_str((http_status)response))); rheaders.CreateHeader("Date", InspIRCd::TimeString(ServerInstance->Time(), "%a, %d %b %Y %H:%M:%S GMT", true)); rheaders.CreateHeader("Server", INSPIRCD_BRANCH); diff --git a/src/modules/m_ircv3_msgid.cpp b/src/modules/m_ircv3_msgid.cpp index d6c603a6b..3e08d5e4a 100644 --- a/src/modules/m_ircv3_msgid.cpp +++ b/src/modules/m_ircv3_msgid.cpp @@ -47,7 +47,7 @@ class MsgIdGenerator final public: MsgIdGenerator() - : strid(InspIRCd::Format("%s~%lu~", ServerInstance->Config->GetSID().c_str(), ServerInstance->startup_time)) + : strid(INSP_FORMAT("{}~{}~", ServerInstance->Config->GetSID(), ServerInstance->startup_time)) , baselen(strid.length()) { } diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index b6c5afb3d..08252532e 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -195,7 +195,8 @@ public: { f->clear(); f->lock(); - memb->chan->WriteNotice(InspIRCd::Format("This channel has been closed to new users for %u seconds because there have been more than %d joins in %d seconds.", duration, f->joins, f->secs)); + memb->chan->WriteNotice(INSP_FORMAT("This channel has been closed to new users for {} seconds because there have been more than {} joins in {} seconds.", + duration, f->joins, f->secs)); } } } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 588adf73c..8634fca10 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -145,7 +145,7 @@ public: const KickRejoinData* data = kr.ext.Get(chan); if ((data) && !invapi->IsInvited(user, chan) && (!data->canjoin(user))) { - user->WriteNumeric(ERR_UNAVAILRESOURCE, chan->name, InspIRCd::Format("You must wait %u seconds after being kicked to rejoin (+J is set)", data->delay)); + user->WriteNumeric(ERR_UNAVAILRESOURCE, chan->name, INSP_FORMAT("You must wait {} seconds after being kicked to rejoin (+J is set)", data->delay)); return MOD_RES_DENY; } } diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index a901b7721..330d50c58 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -89,19 +89,19 @@ public: if (c->HasUser(user)) { - user->WriteNumeric(ERR_KNOCKONCHAN, c->name, InspIRCd::Format("Can't KNOCK on %s, you are already on that channel.", c->name.c_str())); + user->WriteNumeric(ERR_KNOCKONCHAN, c->name, INSP_FORMAT("Can't KNOCK on {}, you are already on that channel.", c->name)); return CmdResult::FAILURE; } if (c->IsModeSet(noknockmode)) { - user->WriteNumeric(ERR_CANNOTKNOCK, InspIRCd::Format("Can't KNOCK on %s, +K is set.", c->name.c_str())); + user->WriteNumeric(ERR_CANNOTKNOCK, INSP_FORMAT("Can't KNOCK on {}, +K is set.", c->name)); return CmdResult::FAILURE; } if (!c->IsModeSet(inviteonlymode)) { - user->WriteNumeric(ERR_CHANOPEN, c->name, InspIRCd::Format("Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str())); + user->WriteNumeric(ERR_CHANOPEN, c->name, INSP_FORMAT("Can't KNOCK on {}, channel is not invite only so knocking is pointless!", c->name)); return CmdResult::FAILURE; } @@ -131,7 +131,7 @@ public: if (notify & KN_SEND_NOTICE) { - c->WriteNotice(InspIRCd::Format("User %s is KNOCKing on %s (%s)", user->nick.c_str(), c->name.c_str(), parameters[1].c_str()), status); + c->WriteNotice(INSP_FORMAT("User {} is KNOCKing on {} ({})", user->nick, c->name, parameters[1]), status); user->WriteNotice("KNOCKing on " + c->name); } diff --git a/src/modules/m_monitor.cpp b/src/modules/m_monitor.cpp index e5cbedc29..3e2b9d514 100644 --- a/src/modules/m_monitor.cpp +++ b/src/modules/m_monitor.cpp @@ -277,7 +277,7 @@ class CommandMonitor final if (result == IRCv3::Monitor::Manager::WR_TOOMANY) { // List is full, send error which includes the remaining nicks that were not processed - user->WriteNumeric(ERR_MONLISTFULL, maxmonitor, InspIRCd::Format("%s%s%s", nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str()), "Monitor list is full"); + user->WriteNumeric(ERR_MONLISTFULL, maxmonitor, INSP_FORMAT("{}{}{}", nick, (ss.StreamEnd() ? "" : ","), ss.GetRemaining()), "Monitor list is full"); break; } else if (result != IRCv3::Monitor::Manager::WR_OK) diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 7bd3fcc14..c830b5b8e 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -158,8 +158,8 @@ public: if (f->islocked()) { - user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("%s has been locked for nickchanges for %u seconds because there have been more than %u nick changes in %u seconds", - memb->chan->name.c_str(), duration, f->nicks, f->secs)); + user->WriteNumeric(ERR_CANTCHANGENICK, INSP_FORMAT("{} has been locked for nickchanges for {} seconds because there have been more than {} nick changes in {} seconds", + memb->chan->name, duration, f->nicks, f->secs)); return MOD_RES_DENY; } @@ -167,7 +167,7 @@ public: { f->clear(); f->lock(); - memb->chan->WriteNotice(InspIRCd::Format("No nick changes are allowed for %u seconds because there have been more than %u nick changes in %u seconds.", + memb->chan->WriteNotice(INSP_FORMAT("No nick changes are allowed for {} seconds because there have been more than {} nick changes in {} seconds.", duration, f->nicks, f->secs)); return MOD_RES_DENY; } diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp index 5bacd2584..a829a9ac9 100644 --- a/src/modules/m_nokicks.cpp +++ b/src/modules/m_nokicks.cpp @@ -49,8 +49,8 @@ public: if (!extban.GetStatus(source, memb->chan).check(!modeset)) { // Can't kick with Q in place, not even opers with override, and founders - source->WriteNumeric(ERR_RESTRICTED, memb->chan->name, InspIRCd::Format("Can't kick user %s from channel (%s)", - memb->user->nick.c_str(), modeset ? "+Q is set" : "you're extbanned")); + source->WriteNumeric(ERR_RESTRICTED, memb->chan->name, INSP_FORMAT("Can't kick user {} from channel ({})", + memb->user->nick, modeset ? "+Q is set" : "you're extbanned")); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index 8b6ee9676..6064c883c 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -59,8 +59,8 @@ public: bool modeset = memb->chan->IsModeSet(nn); if (!extban.GetStatus(user, memb->chan).check(!modeset)) { - user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Can't change nickname while on %s (%s)", - memb->chan->name.c_str(), modeset ? "+N is set" : "you're extbanned")); + user->WriteNumeric(ERR_CANTCHANGENICK, INSP_FORMAT("Can't change nickname while on {} ({})", + memb->chan->name, modeset ? "+N is set" : "you're extbanned")); return MOD_RES_DENY; } } diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp index 10e55a370..f5ed14e09 100644 --- a/src/modules/m_operchans.cpp +++ b/src/modules/m_operchans.cpp @@ -79,7 +79,7 @@ public: { if (!override && chan && chan->IsModeSet(oc) && !user->IsOper()) { - user->WriteNumeric(ERR_CANTJOINOPERSONLY, chan->name, InspIRCd::Format("Only server operators may join %s (+O is set)", chan->name.c_str())); + user->WriteNumeric(ERR_CANTJOINOPERSONLY, chan->name, INSP_FORMAT("Only server operators may join {} (+O is set)", chan->name)); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index ebdc86f16..aa9efdd20 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -51,7 +51,7 @@ public: source->nick.c_str(), source_level, dest->nick.c_str(), dest_level, reason.c_str()); } dest->WriteNotice("*** Oper " + source->nick + " attempted to /KILL you!"); - source->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper %s is a higher level than you", dest->nick.c_str())); + source->WriteNumeric(ERR_NOPRIVILEGES, INSP_FORMAT("Permission Denied - Oper {} is a higher level than you", dest->nick)); return MOD_RES_DENY; } } diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 5c1125340..6c07a8a1d 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -119,7 +119,7 @@ private: } if (NoisyOverride) - chan->WriteRemoteNotice(InspIRCd::Format("%s used oper override to bypass %s", user->nick.c_str(), bypasswhat)); + chan->WriteRemoteNotice(INSP_FORMAT("{} used oper override to bypass {}", user->nick, bypasswhat)); ServerInstance->SNO.WriteGlobalSno('v', user->nick+" used oper override to bypass " + mode + " on " + chan->name); return MOD_RES_ALLOW; } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 521ccb091..7cbe8d7e8 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -57,12 +57,12 @@ public: auto* c = ServerInstance->Channels.Find(parameter); if (!c) { - source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", parameter.c_str())); + source->WriteNumeric(690, INSP_FORMAT("Target channel {} must exist to be set as a redirect.", parameter)); return false; } else if (c->GetPrefixValue(source) < OP_VALUE) { - source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", parameter.c_str())); + source->WriteNumeric(690, INSP_FORMAT("You must be opped on {} to set it as a redirect.", parameter)); return false; } } diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 482477eb7..113062b30 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -83,7 +83,7 @@ public: if (!channel->HasUser(target)) { - user->WriteNotice(InspIRCd::Format("*** User %s is not on channel %s", target->nick.c_str(), channel->name.c_str())); + user->WriteNotice(INSP_FORMAT("*** User {} is not on channel {}", target->nick, channel->name)); return CmdResult::FAILURE; } @@ -129,21 +129,21 @@ public: /* Build up the part reason string. */ std::string reason = "Removed by " + user->nick + ": " + reasonparam; - channel->WriteRemoteNotice(InspIRCd::Format("%s removed %s from the channel", user->nick.c_str(), target->nick.c_str())); + channel->WriteRemoteNotice(INSP_FORMAT("{} removed {} from the channel", user->nick, target->nick)); target->WriteNotice("*** " + user->nick + " removed you from " + channel->name + " with the message: " + reasonparam); channel->PartUser(target, reason); } else { - user->WriteNotice(InspIRCd::Format("*** You do not have access to /REMOVE %s from %s", target->nick.c_str(), channel->name.c_str())); + user->WriteNotice(INSP_FORMAT("*** You do not have access to /REMOVE {} from {}", target->nick, channel->name)); return CmdResult::FAILURE; } } else { /* m_nokicks.so was loaded and +Q was set, block! */ - user->WriteNumeric(ERR_RESTRICTED, channel->name, InspIRCd::Format("Can't remove user %s from channel (+Q is set)", target->nick.c_str())); + user->WriteNumeric(ERR_RESTRICTED, channel->name, INSP_FORMAT("Can't remove user {} from channel (+Q is set)", target->nick)); return CmdResult::FAILURE; } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 33c784a5b..ec2568779 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -318,15 +318,15 @@ private: { if (ms.MaxLines && settings.Lines > ms.MaxLines) { - source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "The line number you specified is too big. Maximum allowed is %lu.", ms.MaxLines))); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, INSP_FORMAT( + "The line number you specified is too big. Maximum allowed is {}.", ms.MaxLines))); return false; } if (ms.MaxSecs && settings.Seconds > ms.MaxSecs) { - source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "The seconds you specified are too big. Maximum allowed is %lu.", ms.MaxSecs))); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, INSP_FORMAT( + "The seconds you specified are too big. Maximum allowed is {}.", ms.MaxSecs))); return false; } @@ -336,8 +336,8 @@ private: source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, "The server administrator has disabled matching on edit distance.")); else - source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "The distance you specified is too big. Maximum allowed is %u.", ms.MaxDiff))); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, INSP_FORMAT( + "The distance you specified is too big. Maximum allowed is {}.", ms.MaxDiff))); return false; } @@ -347,8 +347,8 @@ private: source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, "The server administrator has disabled backlog matching.")); else - source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format( - "The backlog you specified is too big. Maximum allowed is %lu.", ms.MaxBacklog))); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, INSP_FORMAT( + "The backlog you specified is too big. Maximum allowed is {}.", ms.MaxBacklog))); return false; } @@ -438,7 +438,7 @@ public: data["max-diff"] = ConvToStr(rm.ms.MaxDiff); data["max-backlog"] = ConvToStr(rm.ms.MaxBacklog); - compatdata = InspIRCd::Format("%lu:%lu:%u:%lu", rm.ms.MaxLines, rm.ms.MaxSecs, + compatdata = INSP_FORMAT("{}:{}:{}:{}", rm.ms.MaxLines, rm.ms.MaxSecs, rm.ms.MaxDiff, rm.ms.MaxBacklog); } }; diff --git a/src/modules/m_rmode.cpp b/src/modules/m_rmode.cpp index dc1546ccc..4f6361efd 100644 --- a/src/modules/m_rmode.cpp +++ b/src/modules/m_rmode.cpp @@ -53,8 +53,8 @@ public: if (chan->GetPrefixValue(user) < mh->GetLevelRequired(false)) { - user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(chan, mh->GetLevelRequired(false), InspIRCd::Format("unset channel mode %c (%s)", - mh->GetModeChar(), mh->name.c_str()))); + user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(chan, mh->GetLevelRequired(false), INSP_FORMAT("unset channel mode {} ({})", + mh->GetModeChar(), mh->name))); return CmdResult::FAILURE; } diff --git a/src/modules/m_satopic.cpp b/src/modules/m_satopic.cpp index 88beb9274..0fba5b0af 100644 --- a/src/modules/m_satopic.cpp +++ b/src/modules/m_satopic.cpp @@ -51,7 +51,7 @@ public: const std::string newTopic(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic); if (target->topic == newTopic) { - user->WriteNotice(InspIRCd::Format("The topic on %s is already what you are trying to change it to.", target->name.c_str())); + user->WriteNotice(INSP_FORMAT("The topic on {} is already what you are trying to change it to.", target->name)); return CmdResult::SUCCESS; } diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 39401697c..e07c3b973 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -104,9 +104,9 @@ public: // If <securehost:showmsg> is set then tell the user that they need to wait. if (showmsg) { - user->WriteNotice(InspIRCd::Format("*** You cannot view the channel list right now. Please %stry again in %s.", + user->WriteNotice(INSP_FORMAT("*** You cannot view the channel list right now. Please {}try again in {}.", exemptregistered ? "log in to an account or " : "", - Duration::ToString(maxwaittime - ServerInstance->Time()).c_str())); + Duration::ToString(maxwaittime - ServerInstance->Time()))); } // The client might be waiting on a response to do something so send them an diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index c9f25c45b..0cfb262e6 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -93,7 +93,7 @@ public: if ((u->IsModeSet(bm)) && (memb) && (memb->HasMode(pm))) { /* BZZZT, Denied! */ - user->WriteNumeric(ERR_RESTRICTED, chan->name, InspIRCd::Format("You are not permitted to remove privileges from %s services", ServerInstance->Config->Network.c_str())); + user->WriteNumeric(ERR_RESTRICTED, chan->name, INSP_FORMAT("You are not permitted to remove privileges from {} services", ServerInstance->Config->Network)); return MOD_RES_DENY; } } @@ -109,7 +109,7 @@ public: if (dst->IsModeSet(bm)) { - src->WriteNumeric(ERR_KILLDENY, InspIRCd::Format("You are not permitted to kill %s services!", ServerInstance->Config->Network.c_str())); + src->WriteNumeric(ERR_KILLDENY, INSP_FORMAT("You are not permitted to kill {} services!", ServerInstance->Config->Network)); ServerInstance->SNO.WriteGlobalSno('a', src->nick+" tried to kill service "+dst->nick+" ("+reason+")"); return MOD_RES_DENY; } diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index e1534f8dd..00bd92580 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -88,7 +88,7 @@ public: { // A hostname can not contain NUL, LF, CR, or SPACE. if (chr == 0x00 || chr == 0x0A || chr == 0x0D || chr == 0x20) - throw ModuleException(this, InspIRCd::Format("<hostname:charmap> can not contain character 0x%02X (%c)", chr, chr)); + throw ModuleException(this, INSP_FORMAT("<hostname:charmap> can not contain character 0x{:02X} ({})", chr, chr)); newhostmap.set(static_cast<unsigned char>(chr)); } std::swap(newhostmap, cmd.hostmap); diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index c2152cf54..ca06755ca 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -22,7 +22,9 @@ */ + #include "inspircd.h" + #include "commands.h" #include "treeserver.h" #include "treesocket.h" @@ -272,8 +274,8 @@ void CommandFJoin::LowerTS(Channel* chan, time_t TS, const std::string& newname) if (Utils->AnnounceTSChange) { // WriteRemoteNotice is not used here because the message only needs to go to the local server. - chan->WriteNotice(InspIRCd::Format("Creation time of %s changed from %s to %s", newname.c_str(), - InspIRCd::TimeString(chan->age).c_str(), InspIRCd::TimeString(TS).c_str())); + chan->WriteNotice(INSP_FORMAT("Creation time of {} changed from {} to {}", newname, + InspIRCd::TimeString(chan->age), InspIRCd::TimeString(TS))); } // While the name is equal in case-insensitive compare, it might differ in case; use the remote version diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 138a369d6..833e633df 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -166,7 +166,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops) user->WriteNumeric(RPL_LINKS, Current->GetName(), (((Utils->FlatLinks) && (!user->IsOper())) ? ServerInstance->Config->GetServerName() : Parent), - InspIRCd::Format("%d %s", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc().c_str())); + INSP_FORMAT("{} {}", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc())); } void ModuleSpanningTree::HandleLinks(const CommandBase::Params& parameters, User* user) @@ -356,25 +356,25 @@ ModResult ModuleSpanningTree::HandleConnect(const CommandBase::Params& parameter { if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map)) { - user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Server \002%s\002 is ME, not connecting.", x->Name.c_str())); + user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: Server \002{}\002 is ME, not connecting.", x->Name)); return MOD_RES_DENY; } TreeServer* CheckDupe = Utils->FindServer(x->Name); if (!CheckDupe) { - user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Connecting to server: \002%s\002 (%s:%hu)", x->Name.c_str(), (x->HiddenFromStats ? "<hidden>" : x->IPAddr.c_str()), x->Port)); + user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: Connecting to server: \002{}\002 ({}:{})", x->Name, (x->HiddenFromStats ? "<hidden>" : x->IPAddr), x->Port)); ConnectServer(x); return MOD_RES_DENY; } else { - user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), CheckDupe->GetParent()->GetName().c_str())); + user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: Server \002{}\002 already exists on the network and is connected via \002{}\002", x->Name, CheckDupe->GetParent()->GetName())); return MOD_RES_DENY; } } } - user->WriteRemoteNotice(InspIRCd::Format("*** CONNECT: No server matching \002%s\002 could be found in the config file.", parameters[0].c_str())); + user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: No server matching \002{}\002 could be found in the config file.", parameters[0])); return MOD_RES_DENY; } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index da4a60fc6..9e9d66bb7 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -24,8 +24,8 @@ #include "inspircd.h" -#include "xline.h" #include "listmode.h" +#include "xline.h" #include "treesocket.h" #include "treeserver.h" @@ -133,10 +133,11 @@ void TreeSocket::SendServerInfo(TreeServer* from) if (proto_version < PROTO_INSPIRCD_4) { - this->WriteLine(CommandSInfo::Builder(from, "version", InspIRCd::Format("%s. %s :%s", from->rawbranch.c_str(), - from->GetPublicName().c_str(), from->customversion.c_str()))); - this->WriteLine(CommandSInfo::Builder(from, "fullversion", InspIRCd::Format("%s. %s :[%s] %s", from->rawversion.c_str(), - from->GetName().c_str(), from->GetId().c_str(), from->customversion.c_str()))); + this->WriteLine(CommandSInfo::Builder(from, "version", INSP_FORMAT("{}. {} :{}", from->rawbranch, + from->GetPublicName(), from->customversion))); + + this->WriteLine(CommandSInfo::Builder(from, "fullversion", INSP_FORMAT("{}. {} :[{}] {}", from->rawversion, + from->GetName(), from->GetId(), from->customversion))); } } diff --git a/src/modules/m_spanningtree/num.cpp b/src/modules/m_spanningtree/num.cpp index 13d951508..e7dd93231 100644 --- a/src/modules/m_spanningtree/num.cpp +++ b/src/modules/m_spanningtree/num.cpp @@ -52,7 +52,7 @@ CommandNum::Builder::Builder(SpanningTree::RemoteUser* target, const Numeric::Nu : CmdBuilder("NUM") { TreeServer* const server = (numeric.GetServer() ? (static_cast<TreeServer*>(numeric.GetServer())) : Utils->TreeRoot); - push(server->GetId()).push(target->uuid).push(InspIRCd::Format("%03u", numeric.GetNumeric())); + push(server->GetId()).push(target->uuid).push(INSP_FORMAT("{:03}", numeric.GetNumeric())); const CommandBase::Params& params = numeric.GetParams(); if (!params.empty()) { diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index 792245669..36fedb94d 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -21,7 +21,9 @@ */ + #include "inspircd.h" + #include "commands.h" #include "treeserver.h" #include "utils.h" @@ -103,7 +105,7 @@ CmdResult CommandOpertype::HandleRemote(RemoteUser* u, CommandBase::Params& para std::string extra; if (params.GetTags().find("~name") != params.GetTags().end()) { - extra += InspIRCd::Format(" (%susing account \x02%s\x02)", automatic ? "automatically " : "", + extra += INSP_FORMAT(" ({}using account \x02{}\x02)", automatic ? "automatically " : "", u->oper->GetName().c_str()); } diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index da17bf12d..7ec4828be 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -96,7 +96,7 @@ static std::vector<std::string> GetMap(User* user, TreeServer* current, size_t m // Pad with spaces until its at max len, max_len must always be >= my names length buffer.append(max_len - current->GetName().length(), ' '); - buffer += InspIRCd::Format("%5zu [%5.2f%%]", current->UserCount, percent); + buffer += INSP_FORMAT("{:5} [{:5.2}%]", current->UserCount, percent); if (user->IsOper()) { @@ -219,8 +219,10 @@ CmdResult CommandMap::Handle(User* user, const Params& parameters) size_t totusers = ServerInstance->Users.GetUsers().size(); float avg_users = (float) totusers / Utils->serverlist.size(); - user->WriteRemoteNumeric(RPL_MAPUSERS, InspIRCd::Format("%u server%s and %u user%s, average %.2f users per server", - (unsigned int)Utils->serverlist.size(), (Utils->serverlist.size() > 1 ? "s" : ""), (unsigned int)totusers, (totusers > 1 ? "s" : ""), avg_users)); + user->WriteRemoteNumeric(RPL_MAPUSERS, INSP_FORMAT("{} server{} and {} user{}, average {:.2} users per server", + Utils->serverlist.size(), (Utils->serverlist.size() > 1 ? "s" : ""), totusers, + (totusers > 1 ? "s" : ""), avg_users)); + user->WriteRemoteNumeric(RPL_ENDMAP, "End of /MAP"); return CmdResult::SUCCESS; diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp index 7a0df868e..e8e145f25 100644 --- a/src/modules/m_spanningtree/rconnect.cpp +++ b/src/modules/m_spanningtree/rconnect.cpp @@ -42,7 +42,7 @@ CmdResult CommandRConnect::Handle(User* user, const Params& parameters) /* First see if the server which is being asked to connect to another server in fact exists */ if (!Utils->FindServerMask(parameters[0])) { - user->WriteRemoteNotice(InspIRCd::Format("*** RCONNECT: Server \002%s\002 isn't connected to the network!", parameters[0].c_str())); + user->WriteRemoteNotice(INSP_FORMAT("*** RCONNECT: Server \002{}\002 isn't connected to the network!", parameters[0])); return CmdResult::FAILURE; } diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index 437b25324..d938a6225 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -44,13 +44,13 @@ CmdResult CommandRSQuit::Handle(User* user, const Params& parameters) server_target = Utils->FindServerMask(parameters[0]); if (!server_target) { - user->WriteRemoteNotice(InspIRCd::Format("*** RSQUIT: Server \002%s\002 isn't connected to the network!", parameters[0].c_str())); + user->WriteRemoteNotice(INSP_FORMAT("*** RSQUIT: Server \002{}\002 isn't connected to the network!", parameters[0])); return CmdResult::FAILURE; } if (server_target->IsRoot()) { - user->WriteRemoteNotice(InspIRCd::Format("*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)", parameters[0].c_str())); + user->WriteRemoteNotice(INSP_FORMAT("*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! ({} matches local server name)", parameters[0])); return CmdResult::FAILURE; } diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index a30da84c8..4b9817c23 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -181,17 +181,17 @@ private: ssl_cert* cert = sslapi.GetCertificate(target); if (!cert) { - source->WriteNotice(InspIRCd::Format("*** %s is not connected using TLS.", target->nick.c_str())); + source->WriteNotice(INSP_FORMAT("*** {} is not connected using TLS.", target->nick)); } else if (cert->GetError().length()) { - source->WriteNotice(InspIRCd::Format("*** %s is connected using TLS but has not specified a valid client certificate (%s).", - target->nick.c_str(), cert->GetError().c_str())); + source->WriteNotice(INSP_FORMAT("*** {} is connected using TLS but has not specified a valid client certificate ({}).", + target->nick, cert->GetError())); } else if (!verbose) { - source->WriteNotice(InspIRCd::Format("*** %s is connected using TLS with a valid client certificate (%s).", - target->nick.c_str(), cert->GetFingerprint().c_str())); + source->WriteNotice(INSP_FORMAT("*** {} is connected using TLS with a valid client certificate ({}).", + target->nick, cert->GetFingerprint())); } else { @@ -243,9 +243,9 @@ private: if (sslonlymode) { - source->WriteNotice(InspIRCd::Format("*** %s %s have channel mode +%c (%s) set.", - chan->name.c_str(), chan->IsModeSet(sslonlymode) ? "does" : "does not", - sslonlymode->GetModeChar(), sslonlymode->name.c_str())); + source->WriteNotice(INSP_FORMAT("*** {} {} have channel mode +{} ({}) set.", + chan->name, chan->IsModeSet(sslonlymode) ? "does" : "does not", + sslonlymode->GetModeChar(), sslonlymode->name)); } for (const auto& [u, _] : chan->GetUsers()) @@ -317,7 +317,7 @@ public: { whois.SendLine(RPL_WHOISSECURE, "is using a secure connection"); if ((!cmd.operonlyfp || whois.IsSelfWhois() || whois.GetSource()->IsOper()) && !cert->fingerprint.empty()) - whois.SendLine(RPL_WHOISCERTFP, InspIRCd::Format("has TLS client certificate fingerprint %s", cert->fingerprint.c_str())); + whois.SendLine(RPL_WHOISCERTFP, INSP_FORMAT("has TLS client certificate fingerprint {}", cert->fingerprint)); } } diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index d0a184cf3..150aca0b5 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -100,7 +100,7 @@ public: if (nonssl) { - source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, InspIRCd::Format("All members of the channel must be connected via TLS (%zu/%zu are non-TLS)", + source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, INSP_FORMAT("All members of the channel must be connected via TLS ({}/{} are non-TLS)", nonssl, channel->GetUsers().size())); return false; } diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index 81562d78c..291ded353 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -217,7 +217,7 @@ public: if (rl) { - user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Services reserved nickname: %s", rl->reason.c_str())); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, INSP_FORMAT("Services reserved nickname: {}", rl->reason)); return MOD_RES_DENY; } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index db41acaff..c3986ac70 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -151,8 +151,8 @@ public: if (sendnotice) { - const std::string message = InspIRCd::Format("Timed ban %s added by %s on %s lasting for %s.", - mask.c_str(), user->nick.c_str(), channel->name.c_str(), Duration::ToString(duration).c_str()); + const std::string message = INSP_FORMAT("Timed ban {} added by {} on {} lasting for {}.", + mask, user->nick, channel->name, Duration::ToString(duration)); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); @@ -256,8 +256,8 @@ public: { if (cmd.sendnotice) { - const std::string message = InspIRCd::Format("Timed ban %s set by %s on %s has expired.", - timedban.mask.c_str(), timedban.setter.c_str(), timedban.chan->name.c_str()); + const std::string message = INSP_FORMAT("Timed ban {} set by {} on {} has expired.", + timedban.mask, timedban.setter, timedban.chan->name); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); diff --git a/src/modules/m_tline.cpp b/src/modules/m_tline.cpp index caa942ec9..52bb3cec4 100644 --- a/src/modules/m_tline.cpp +++ b/src/modules/m_tline.cpp @@ -63,10 +63,11 @@ public: if (n_matched) { float p = (n_matched / (float)n_counted) * 100; - user->WriteNotice(InspIRCd::Format("*** TLINE: Counted %lu user(s). Matched '%s' against %u user(s) (%0.2f%% of the userbase). %u by hostname and %u by IP address.", n_counted, parameters[0].c_str(), n_matched, p, n_match_host, n_match_ip)); + user->WriteNotice(INSP_FORMAT("*** TLINE: Counted {} user(s). Matched '{}' against {} user(s) ({:0.2}% of the userbase). {} by hostname and {} by IP address.", + n_counted, parameters[0], n_matched, p, n_match_host, n_match_ip)); } else - user->WriteNotice(InspIRCd::Format("*** TLINE: Counted %lu user(s). Matched '%s' against no user(s).", n_counted, parameters[0].c_str())); + user->WriteNotice(INSP_FORMAT("*** TLINE: Counted {} user(s). Matched '{}' against no user(s).", n_counted, parameters[0])); return CmdResult::SUCCESS; } diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 6071e30bf..a4a7ad1c1 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -95,7 +95,7 @@ public: { Numeric::Numeric n(ERR_NOTINVITED); n.SetServer(user->server); - n.push(u->nick).push(c->name).push(InspIRCd::Format("Is not invited to channel %s", c->name.c_str())); + n.push(u->nick).push(c->name).push(INSP_FORMAT("Is not invited to channel {}", c->name)); user->WriteRemoteNumeric(n); return CmdResult::FAILURE; } @@ -105,8 +105,8 @@ public: n.push(c->name).push(u->nick).push("Uninvited"); user->WriteRemoteNumeric(n); - lu->WriteNumeric(RPL_UNINVITED, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str())); - c->WriteRemoteNotice(InspIRCd::Format("*** %s uninvited %s.", user->nick.c_str(), u->nick.c_str())); + lu->WriteNumeric(RPL_UNINVITED, INSP_FORMAT("You were uninvited from {} by {}", c->name, user->nick)); + c->WriteRemoteNotice(INSP_FORMAT("*** {} uninvited {}.", user->nick, u->nick)); } return CmdResult::SUCCESS; diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 6299bdc17..61b20bcf6 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -113,7 +113,7 @@ class CommandWatch final // Do not show how many clients are watching this nick, it's pointless const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); - user->WriteNumeric(RPL_WATCHSTAT, InspIRCd::Format("You have %lu and are on 0 WATCH entries", (unsigned long)list.size())); + user->WriteNumeric(RPL_WATCHSTAT, INSP_FORMAT("You have {} and are on 0 WATCH entries", list.size())); Numeric::Builder<' '> out(user, RPL_WATCHLIST); for (const auto* entry : list) |
