diff options
| author | 2024-08-18 16:04:36 +0100 | |
|---|---|---|
| committer | 2024-08-18 16:19:12 +0100 | |
| commit | d95be0a5165cf3cee3d1feedab1bdbdf21e5e419 (patch) | |
| tree | 20cdde19d3319c1423e63e37e5b26da6d5dad61b /include | |
| parent | Document 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.h | 10 | ||||
| -rw-r--r-- | include/modules/ircv3_replies.h | 4 | ||||
| -rw-r--r-- | include/users.h | 20 |
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. */ |
