aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar Sadie Powell2024-08-18 16:04:36 +0100
committerGravatar Sadie Powell2024-08-18 16:19:12 +0100
commitd95be0a5165cf3cee3d1feedab1bdbdf21e5e419 (patch)
tree20cdde19d3319c1423e63e37e5b26da6d5dad61b /include
parentDocument Write* members in the User type correctly. (diff)
Add a formatting overload to {Membership,User}::Write(Remote)Notice.
Diffstat (limited to 'include')
-rw-r--r--include/membership.h10
-rw-r--r--include/modules/ircv3_replies.h4
-rw-r--r--include/users.h20
3 files changed, 32 insertions, 2 deletions
diff --git a/include/membership.h b/include/membership.h
index 1d08ec027..f54ef32e0 100644
--- a/include/membership.h
+++ b/include/membership.h
@@ -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)...));
+ }
};
diff --git a/include/modules/ircv3_replies.h b/include/modules/ircv3_replies.h
index 4bfc8a30b..c92e257e9 100644
--- a/include/modules/ircv3_replies.h
+++ b/include/modules/ircv3_replies.h
@@ -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:
diff --git a/include/users.h b/include/users.h
index f6dd59a0d..b7be744eb 100644
--- a/include/users.h
+++ b/include/users.h
@@ -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.
*/