diff options
author | Sadie Powell <sadie@witchery.services> | 2024-02-21 16:35:27 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-02-22 00:14:08 +0000 |
commit | c4ab550ec719a80abada719dbe8680be806c370f (patch) | |
tree | 371e5b11134303336719c9a18affdfeab3afcb25 /include/uplink.h | |
parent | 3ecf6b495b02bdabe317547fe4bcf2179e3fb6d7 (diff) |
Add Uplink::Send, rework message formatting.
This is the new way of sending messages to the uplink inspired by
the work done in the old git master. This will allow us to do new
things involving tags in the future.
Diffstat (limited to 'include/uplink.h')
-rw-r--r-- | include/uplink.h | 28 |
1 files changed, 27 insertions, 1 deletions
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; |