mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Add a formatting overload to {Membership,User}::Write(Remote)Notice.
This commit is contained in:
parent
ca78bc4a0e
commit
d95be0a516
@ -134,4 +134,14 @@ public:
|
||||
* @param text The contents of the message to send.
|
||||
*/
|
||||
void WriteNotice(const std::string& text) const;
|
||||
|
||||
/** Sends a server notice to this user in the context of this channel.
|
||||
* @param text A format string to format and then send.
|
||||
* @param p One or more arguments to format the string with.
|
||||
*/
|
||||
template <typename... Param>
|
||||
void WriteNotice(const char* text, Param&&... p)
|
||||
{
|
||||
WriteNotice(fmt::format(text, std::forward<Param>(p)...));
|
||||
}
|
||||
};
|
||||
|
@ -67,9 +67,9 @@ private:
|
||||
void SendNoticeInternal(LocalUser* user, const Command* command, const std::string& description)
|
||||
{
|
||||
if (command)
|
||||
user->WriteNotice(INSP_FORMAT("*** {}: {}", command->name, description));
|
||||
user->WriteNotice("*** {}: {}", command->name, description);
|
||||
else
|
||||
user->WriteNotice(INSP_FORMAT("*** {}", description));
|
||||
user->WriteNotice("*** {}", description);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -665,11 +665,31 @@ public:
|
||||
*/
|
||||
void WriteNotice(const std::string& text);
|
||||
|
||||
/** Sends a server notice to this user.
|
||||
* @param text A format string to format and then send.
|
||||
* @param p One or more arguments to format the string with.
|
||||
*/
|
||||
template <typename... Param>
|
||||
void WriteNotice(const char* text, Param&&... p)
|
||||
{
|
||||
WriteNotice(fmt::format(text, std::forward<Param>(p)...));
|
||||
}
|
||||
|
||||
/** Sends a server notice from the local server to the user.
|
||||
* @param text The message to send.
|
||||
*/
|
||||
virtual void WriteRemoteNotice(const std::string& text);
|
||||
|
||||
/** Sends a server notice to this user.
|
||||
* @param text A format string to format and then send.
|
||||
* @param p One or more arguments to format the string with.
|
||||
*/
|
||||
template <typename... Param>
|
||||
void WriteRemoteNotice(const char* text, Param&&... p)
|
||||
{
|
||||
WriteRemoteNotice(fmt::format(text, std::forward<Param>(p)...));
|
||||
}
|
||||
|
||||
/** Sends a notice to this user.
|
||||
* @param numeric The numeric to send.
|
||||
*/
|
||||
|
@ -516,7 +516,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string& useruid)
|
||||
|
||||
// If a user is rehashing, tell them directly
|
||||
if (user)
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** {}", line));
|
||||
user->WriteRemoteNotice("*** {}", line);
|
||||
// Also tell opers
|
||||
ServerInstance->SNO.WriteGlobalSno('r', line);
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User
|
||||
const char* article = strchr("AEIOUaeiou", bantype) ? "an" : "a";
|
||||
ServerInstance->SNO.WriteToSnoMask('x', "\002WARNING\002: {} tried to set add {} {}-line on {} which covers {:.2}% of the network which is more than the maximum of {:.2}%!",
|
||||
user->nick, article, bantype, mask, percent, itrigger);
|
||||
user->WriteNotice(INSP_FORMAT("*** Unable to add {} {}-line on {} which covers {:.2}% of the network which is more than the maximum of {:.2}%!",
|
||||
article, bantype, mask, percent, itrigger));
|
||||
user->WriteNotice("*** Unable to add {} {}-line on {} which covers {:.2}% of the network which is more than the maximum of {:.2}%!",
|
||||
article, bantype, mask, percent, itrigger);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -500,13 +500,13 @@ public:
|
||||
if (count)
|
||||
{
|
||||
// TODO: replace this with a FAIL stdrpl when we can network those.
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** DNSBL: Unable to recheck {}: still waiting on {} DNSBLs from the previous check.",
|
||||
ltarget->nick, count));
|
||||
user->WriteRemoteNotice("*** DNSBL: Unable to recheck {}: still waiting on {} DNSBLs from the previous check.",
|
||||
ltarget->nick, count);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
// TODO: replace this with a NOTE stdrpl when we can network those.
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** DNSBL: Rechecking {} against {} DNSBLs.", ltarget->nick, data.dnsbls.size()));
|
||||
user->WriteRemoteNotice("*** DNSBL: Rechecking {} against {} DNSBLs.", ltarget->nick, data.dnsbls.size());
|
||||
|
||||
const bool has_reason = parameters.size() > 1;
|
||||
ServerInstance->SNO.WriteGlobalSno('d', "{} is rechecking whether {} ({}) is in a DNSBL{}{}", user->nick,
|
||||
|
@ -164,20 +164,20 @@ public:
|
||||
}
|
||||
|
||||
uint32_t addr = sa.in4.sin_addr.s_addr;
|
||||
user->WriteNotice(INSP_FORMAT("*** HEXIP: {} encodes to {:02x}{:02x}{:02x}{:02x}.",
|
||||
user->WriteNotice("*** HEXIP: {} encodes to {:02x}{:02x}{:02x}{:02x}.",
|
||||
sa.addr(), (addr & 0xFF), ((addr >> 8) & 0xFF), ((addr >> 16) & 0xFF),
|
||||
((addr >> 24) & 0xFF)));
|
||||
((addr >> 24) & 0xFF));
|
||||
return CmdResult::SUCCESS;
|
||||
}
|
||||
|
||||
if (ParseIP(parameters[0], sa))
|
||||
{
|
||||
user->WriteNotice(INSP_FORMAT("*** HEXIP: {} decodes to {}.", parameters[0], sa.addr()));
|
||||
user->WriteNotice("*** HEXIP: {} decodes to {}.", parameters[0], sa.addr());
|
||||
return CmdResult::SUCCESS;
|
||||
}
|
||||
|
||||
user->WriteNotice(INSP_FORMAT("*** HEXIP: {} is not a valid raw or hex encoded IPv4 address.",
|
||||
parameters[0]));
|
||||
user->WriteNotice("*** HEXIP: {} is not a valid raw or hex encoded IPv4 address.",
|
||||
parameters[0]);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ private:
|
||||
if (memb)
|
||||
memb->WriteNotice(message);
|
||||
else
|
||||
user->WriteNotice(INSP_FORMAT("[{}] {}", chan->name, message));
|
||||
user->WriteNotice("[{}] {}", chan->name, message);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
|
||||
if (!channel->HasUser(target))
|
||||
{
|
||||
user->WriteNotice(INSP_FORMAT("*** User {} is not on channel {}", target->nick, channel->name));
|
||||
user->WriteNotice("*** User {} is not on channel {}", target->nick, channel->name);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
user->WriteNotice(INSP_FORMAT("*** You do not have access to /REMOVE {} from {}", target->nick, channel->name));
|
||||
user->WriteNotice("*** You do not have access to /REMOVE {} from {}", target->nick, channel->name);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
const std::string newTopic(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic);
|
||||
if (target->topic == newTopic)
|
||||
{
|
||||
user->WriteNotice(INSP_FORMAT("The topic on {} is already what you are trying to change it to.", target->name));
|
||||
user->WriteNotice("The topic on {} is already what ou are trying to change it to.", target->name);
|
||||
return CmdResult::SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -120,9 +120,9 @@ public:
|
||||
{
|
||||
if (waittime)
|
||||
{
|
||||
user->WriteNotice(INSP_FORMAT("*** You cannot view the channel list right now. Please {}try again in {}.",
|
||||
user->WriteNotice("*** You cannot view the channel list right now. Please {}try again in {}.",
|
||||
exemptregistered ? "log in to an account or " : "",
|
||||
Duration::ToString(maxwaittime - ServerInstance->Time())));
|
||||
Duration::ToString(maxwaittime - ServerInstance->Time()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
const std::string& userhost = dest->HasPrivPermission("users/auspex")
|
||||
? src->GetRealUserHost()
|
||||
: src->GetUserHost();
|
||||
dest->WriteNotice(INSP_FORMAT("{} ({}) did a /WHOIS on you", src->nick, userhost));
|
||||
dest->WriteNotice("{} ({}) did a /WHOIS on you", src->nick, userhost);
|
||||
}
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
|
@ -351,25 +351,25 @@ ModResult ModuleSpanningTree::HandleConnect(const CommandBase::Params& parameter
|
||||
{
|
||||
if (InspIRCd::Match(ServerInstance->Config->ServerName, x->Name, ascii_case_insensitive_map))
|
||||
{
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: Server \002{}\002 is ME, not connecting.", x->Name));
|
||||
user->WriteRemoteNotice("*** CONNECT: Server \002{}\002 is ME, not connecting.", x->Name);
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
TreeServer* CheckDupe = Utils->FindServer(x->Name);
|
||||
if (!CheckDupe)
|
||||
{
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: Connecting to server: \002{}\002 ({}:{})", x->Name, (x->HiddenFromStats ? "<hidden>" : x->IPAddr), x->Port));
|
||||
user->WriteRemoteNotice("*** CONNECT: Connecting to server: \002{}\002 ({}:{})", x->Name, (x->HiddenFromStats ? "<hidden>" : x->IPAddr), x->Port);
|
||||
ConnectServer(x);
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
else
|
||||
{
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** CONNECT: Server \002{}\002 already exists on the network and is connected via \002{}\002", x->Name, CheckDupe->GetParent()->GetName()));
|
||||
user->WriteRemoteNotice("*** 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(INSP_FORMAT("*** CONNECT: No server matching \002{}\002 could be found in the config file.", parameters[0]));
|
||||
user->WriteRemoteNotice("*** CONNECT: No server matching \002{}\002 could be found in the config file.", parameters[0]);
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
|
@ -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(INSP_FORMAT("*** RCONNECT: Server \002{}\002 isn't connected to the network!", parameters[0]));
|
||||
user->WriteRemoteNotice("*** RCONNECT: Server \002{}\002 isn't connected to the network!", parameters[0]);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ CmdResult CommandRSQuit::Handle(User* user, const Params& parameters)
|
||||
server_target = Utils->FindServerMask(parameters[0]);
|
||||
if (!server_target)
|
||||
{
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** RSQUIT: Server \002{}\002 isn't connected to the network!", parameters[0]));
|
||||
user->WriteRemoteNotice("*** RSQUIT: Server \002{}\002 isn't connected to the network!", parameters[0]);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
if (server_target->IsRoot())
|
||||
{
|
||||
user->WriteRemoteNotice(INSP_FORMAT("*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! ({} matches local server name)", parameters[0]));
|
||||
user->WriteRemoteNotice("*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! ({} matches local server name)", parameters[0]);
|
||||
return CmdResult::FAILURE;
|
||||
}
|
||||
|
||||
|
@ -199,17 +199,17 @@ private:
|
||||
ssl_cert* cert = sslapi.GetCertificate(target);
|
||||
if (!cert)
|
||||
{
|
||||
source->WriteNotice(INSP_FORMAT("*** {} is not connected using TLS.", target->nick));
|
||||
source->WriteNotice("*** {} is not connected using TLS.", target->nick);
|
||||
}
|
||||
else if (cert->GetError().length())
|
||||
{
|
||||
source->WriteNotice(INSP_FORMAT("*** {} is connected using TLS but has not specified a valid client certificate ({}).",
|
||||
target->nick, cert->GetError()));
|
||||
source->WriteNotice("*** {} is connected using TLS but has not specified a valid client certificate ({}).",
|
||||
target->nick, cert->GetError());
|
||||
}
|
||||
else if (!verbose)
|
||||
{
|
||||
source->WriteNotice(INSP_FORMAT("*** {} is connected using TLS with a valid client certificate ({}).",
|
||||
target->nick, cert->GetFingerprint()));
|
||||
source->WriteNotice("*** {} is connected using TLS with a valid client certificate ({}).",
|
||||
target->nick, cert->GetFingerprint());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -262,9 +262,9 @@ private:
|
||||
|
||||
if (sslonlymode)
|
||||
{
|
||||
source->WriteNotice(INSP_FORMAT("*** {} {} have channel mode +{} ({}) set.",
|
||||
source->WriteNotice("*** {} {} have channel mode +{} ({}) set.",
|
||||
chan->name, chan->IsModeSet(sslonlymode) ? "does" : "does not",
|
||||
sslonlymode->GetModeChar(), sslonlymode->name));
|
||||
sslonlymode->GetModeChar(), sslonlymode->name);
|
||||
}
|
||||
|
||||
for (const auto& [u, _] : chan->GetUsers())
|
||||
|
@ -62,11 +62,11 @@ public:
|
||||
if (n_matched)
|
||||
{
|
||||
float p = (n_matched / (float)n_counted) * 100;
|
||||
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));
|
||||
user->WriteNotice("*** 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(INSP_FORMAT("*** TLINE: Counted {} user(s). Matched '{}' against no user(s).", n_counted, parameters[0]));
|
||||
user->WriteNotice("*** TLINE: Counted {} user(s). Matched '{}' against no user(s).", n_counted, parameters[0]);
|
||||
|
||||
return CmdResult::SUCCESS;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user