summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-02-14 04:04:44 +0000
committerSadie Powell <sadie@witchery.services>2020-02-14 04:05:54 +0000
commit7324001939c567c60f5bd08407d20e228f808722 (patch)
tree0f8d373fef66ddfca3cbf0de242e62c102aa2590
parent98b470674b740faf83507214a8d41f63eec279a5 (diff)
Add overloads of SendIfCap to the standard replies API.
-rw-r--r--include/modules/ircv3_replies.h57
1 files changed, 56 insertions, 1 deletions
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<typename T1>
+ 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<typename T1, typename T2>
+ 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<typename T1, typename T2, typename T3>
+ 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<typename T1, typename T2, typename T3, typename T4>
+ 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<typename T1, typename T2, typename T3, typename T4, typename T5>
+ 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);
}
};