diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/anope.h | 5 | ||||
| -rw-r--r-- | include/protocol.h | 14 | ||||
| -rw-r--r-- | include/uplink.h | 28 |
3 files changed, 44 insertions, 3 deletions
diff --git a/include/anope.h b/include/anope.h index 7ffc90729..0f181c87f 100644 --- a/include/anope.h +++ b/include/anope.h @@ -728,6 +728,11 @@ public: /** Convert something to a string */ +inline Anope::string stringify(const Anope::string &x) +{ + return x; +} + template<typename T> inline Anope::string stringify(const T &x) { std::ostringstream stream; diff --git a/include/protocol.h b/include/protocol.h index 29943d0e0..ec4570490 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -51,10 +51,20 @@ public: * @return If the message was well formed then true; otherwise, false. */ virtual bool Parse(const Anope::string &message, Anope::map<Anope::string> &tags, Anope::string &source, Anope::string &command, std::vector<Anope::string> ¶ms); - virtual Anope::string Format(const Anope::string &source, const Anope::string &message); + + /* Formats an outgoing message so it can be sent to the IRC server. + * @param message The location to store the formatted message. + * @param tags IRCv3 message tags. + * @param source Source of the message. + * @param command Command name. + * @param params Any extra parameters. + * @return If the message was formatted then true; otherwise, false. + */ + virtual bool Format(Anope::string &message, const Anope::map<Anope::string> &tags, const MessageSource &source, const Anope::string &command, const std::vector<Anope::string> ¶ms); /* Modes used by default by our clients */ Anope::string DefaultPseudoclientModes = "+io"; + /* Can we force change a users's nick? */ bool CanSVSNick = false; @@ -279,7 +289,7 @@ class CoreExport MessageSource final Server *s = nullptr; public: - MessageSource(const Anope::string &); + explicit MessageSource(const Anope::string &); MessageSource(User *u); MessageSource(Server *s); const Anope::string &GetName() const; diff --git a/include/uplink.h b/include/uplink.h index 72622de7b..20bd26f80 100644 --- a/include/uplink.h +++ b/include/uplink.h @@ -13,10 +13,36 @@ #include "sockets.h" #include "protocol.h" +#include "servers.h" namespace Uplink { extern void Connect(); + extern CoreExport void SendInternal(const Anope::map<Anope::string> &, const MessageSource &, const Anope::string &, const std::vector<Anope::string> &); + + template<typename... Args> + void Send(const Anope::map<Anope::string> &tags, const MessageSource &source, const Anope::string &command, Args &&...args) + { + SendInternal(tags, source, command, { stringify(args)... }); + } + + template<typename... Args> + void Send(const Anope::map<Anope::string> &tags, const Anope::string &command, Args &&...args) + { + SendInternal(tags, Me, command, { stringify(args)... }); + } + + template<typename... Args> + void Send(const MessageSource &source, const Anope::string &command, Args &&...args) + { + SendInternal({}, source, command, { stringify(args)... }); + } + + template<typename... Args> + void Send(const Anope::string &command, Args &&...args) + { + SendInternal({}, Me, command, { stringify(args)... }); + } } /* This is the socket to our uplink */ @@ -33,7 +59,7 @@ public: void OnError(const Anope::string &) override; /* A message sent over the uplink socket */ - class CoreExport Message final + class CoreExport [[deprecated]] Message final { MessageSource source; std::stringstream buffer; |
