From 7324001939c567c60f5bd08407d20e228f808722 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 14 Feb 2020 04:04:44 +0000 Subject: Add overloads of SendIfCap to the standard replies API. --- include/modules/ircv3_replies.h | 57 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/modules/ircv3_replies.h b/include/modules/ircv3_replies.h index f87b267a2..da895f325 100644 --- a/include/modules/ircv3_replies.h +++ b/include/modules/ircv3_replies.h @@ -52,6 +52,11 @@ class IRCv3::Replies::Reply user->Send(ev); } + void SendNoticeInternal(LocalUser* user, Command* command, const std::string& description) + { + user->WriteNotice(InspIRCd::Format("*** %s: %s", command->name.c_str(), description.c_str())); + } + protected: /** Initializes a new instance of the Reply class. * @param Creator The module which created this instance. @@ -163,7 +168,57 @@ class IRCv3::Replies::Reply if (cap.get(user)) Send(user, command, code, description); else - user->WriteNotice(InspIRCd::Format("*** %s: %s", command->name.c_str(), description.c_str())); + SendNoticeInternal(user, command, description); + } + + template + void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, + const T1& p1, const std::string& description) + { + if (cap.get(user)) + SendIfCap(user, command, code, p1, description); + else + SendNoticeInternal(user, command, description); + } + + template + void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, + const T1& p1, const T2& p2, const std::string& description) + { + if (cap.get(user)) + SendIfCap(user, command, code, p1, p2, description); + else + SendNoticeInternal(user, command, description); + } + + template + void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, + const T1& p1, const T2& p2, const T3& p3, const std::string& description) + { + if (cap.get(user)) + SendIfCap(user, command, code, p1, p2, p3, description); + else + SendNoticeInternal(user, command, description); + } + + template + void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, + const T1& p1, const T2& p2, const T3& p3, const T4& p4, const std::string& description) + { + if (cap.get(user)) + SendIfCap(user, command, code, p1, p2, p3, p4, description); + else + SendNoticeInternal(user, command, description); + } + + template + void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, + const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5, const std::string& description) + { + if (cap.get(user)) + SendIfCap(user, command, code, p1, p2, p3, p4, p5, description); + else + SendNoticeInternal(user, command, description); } }; -- cgit v1.2.3