mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Add Numeric::push_fmt(...) as shorthand for push(INSP_FORMAT(...)).
This commit is contained in:
parent
d95be0a516
commit
15e7db5a21
@ -128,6 +128,17 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Formats the string with the specified arguments and adds them to the numeric.
|
||||
* @param text A format string to format and then push.
|
||||
* @param p One or more arguments to format the string with.
|
||||
*/
|
||||
template <typename... Args>
|
||||
Numeric& push_fmt(const char* text, Args&&... args)
|
||||
{
|
||||
push(fmt::format(text, std::forward<Args>(args)...));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Set the source server of the numeric. The source server defaults to the local server.
|
||||
* @param server Server to set as source
|
||||
*/
|
||||
|
@ -54,8 +54,8 @@ public:
|
||||
: Numeric(ERR_CANNOTSENDTOCHAN)
|
||||
{
|
||||
push(chan->name);
|
||||
push(INSP_FORMAT("You cannot send {} to this channel whilst the +{} ({}) mode is set.",
|
||||
what, mh->GetModeChar(), mh->name));
|
||||
push_fmt("You cannot send {} to this channel whilst the +{} ({}) mode is set.", what,
|
||||
mh->GetModeChar(), mh->name);
|
||||
}
|
||||
|
||||
#ifdef INSPIRCD_EXTBAN
|
||||
@ -63,8 +63,8 @@ public:
|
||||
: Numeric(ERR_CANNOTSENDTOCHAN)
|
||||
{
|
||||
push(chan->name);
|
||||
push(INSP_FORMAT("You cannot send {} to this channel whilst {} {}: ({}) extban is set matching you.",
|
||||
what, strchr("AEIOUaeiou", xb.GetLetter()) ? "an" : "a", xb.GetLetter(), xb.GetName()));
|
||||
push_fmt("You cannot send {} to this channel whilst {} {}: ({}) extban is set matching you.",
|
||||
what, strchr("AEIOUaeiou", xb.GetLetter()) ? "an" : "a", xb.GetLetter(), xb.GetName());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -79,8 +79,8 @@ public:
|
||||
: Numeric(ERR_CANNOTSENDTOUSER)
|
||||
{
|
||||
push(user->connected & User::CONN_NICK ? user->nick : "*");
|
||||
push(INSP_FORMAT("You cannot send {} to this user whilst {} have the +{} ({}) mode set.",
|
||||
what, self ? "you" : "they", mh->GetModeChar(), mh->name));
|
||||
push_fmt("You cannot send {} to this user whilst {} have the +{} ({}) mode set.",
|
||||
what, self ? "you" : "they", mh->GetModeChar(), mh->name);
|
||||
}
|
||||
};
|
||||
|
||||
@ -95,9 +95,9 @@ public:
|
||||
|
||||
const PrefixMode* pm = ServerInstance->Modes.FindNearestPrefixMode(rank);
|
||||
if (pm)
|
||||
push(INSP_FORMAT("You must be a channel {} or higher to {}.", pm->name, message));
|
||||
push_fmt("You must be a channel {} or higher to {}.", pm->name, message);
|
||||
else
|
||||
push(INSP_FORMAT("You do not have the required channel privileges to {}.", message));
|
||||
push_fmt("You do not have the required channel privileges to {}.", message);
|
||||
}
|
||||
};
|
||||
|
||||
@ -119,12 +119,12 @@ private:
|
||||
if (!syntax.empty())
|
||||
{
|
||||
// If the mode has a syntax hint we include it in the message.
|
||||
push(INSP_FORMAT("Invalid {} mode parameter. Syntax: {}.", mode->name, syntax));
|
||||
push_fmt("Invalid {} mode parameter. Syntax: {}.", mode->name, syntax);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, send it without.
|
||||
push(INSP_FORMAT("Invalid {} mode parameter.", mode->name));
|
||||
push_fmt("Invalid {} mode parameter.", mode->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ public:
|
||||
klass->GetName(), error);
|
||||
|
||||
errnum = ERR_PASSWDMISMATCH;
|
||||
errnum->push(INSP_FORMAT("A password is required and {}.", error));
|
||||
errnum->push_fmt("A password is required and {}.", error);
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
{
|
||||
Numeric::Numeric n(ERR_NOTINVITED);
|
||||
n.SetServer(user->server);
|
||||
n.push(u->nick).push(c->name).push(INSP_FORMAT("Is not invited to channel {}", c->name));
|
||||
n.push(u->nick, c->name).push_fmt("Is not invited to channel {}", c->name);
|
||||
user->WriteRemoteNumeric(n);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user