summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-22 12:18:25 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-22 12:40:37 +0100
commit438a088b5176068c753aebe860e2d89fefe09eb4 (patch)
tree0096a6ce78ccc06fb89cbeca1065f191e66180f7 /src/modules
parent9cf381330eab69d7e5bf26684d1ec8075aee60a2 (diff)
Add the time tag on the server the message originates from.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_ircv3_servertime.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/modules/m_ircv3_servertime.cpp b/src/modules/m_ircv3_servertime.cpp
index ec6e48daa..3e059719d 100644
--- a/src/modules/m_ircv3_servertime.cpp
+++ b/src/modules/m_ircv3_servertime.cpp
@@ -20,8 +20,12 @@
#include "inspircd.h"
#include "modules/ircv3.h"
#include "modules/ircv3_servertime.h"
+#include "modules/server.h"
-class ServerTimeTag : public IRCv3::ServerTime::Manager, public IRCv3::CapTag<ServerTimeTag>
+class ServerTimeTag
+ : public IRCv3::ServerTime::Manager
+ , public IRCv3::CapTag<ServerTimeTag>
+ , public ServerProtocol::MessageEventListener
{
time_t lasttime;
long lasttimens;
@@ -45,6 +49,7 @@ class ServerTimeTag : public IRCv3::ServerTime::Manager, public IRCv3::CapTag<Se
ServerTimeTag(Module* mod)
: IRCv3::ServerTime::Manager(mod)
, IRCv3::CapTag<ServerTimeTag>(mod, "server-time", "time")
+ , ServerProtocol::MessageEventListener(mod)
, lasttime(0)
, lasttimens(0)
{
@@ -53,9 +58,18 @@ class ServerTimeTag : public IRCv3::ServerTime::Manager, public IRCv3::CapTag<Se
const std::string* GetValue(const ClientProtocol::Message& msg)
{
+ // Client protocol.
RefreshTimeString();
return &lasttimestring;
}
+
+ void OnBuildMessage(User* source, const char* command, ClientProtocol::TagMap& tags) CXX11_OVERRIDE
+ {
+ // Server protocol.
+ RefreshTimeString();
+ tags.insert(std::make_pair(tagname, ClientProtocol::MessageTagData(this, lasttimestring)));
+ }
+
};
class ModuleIRCv3ServerTime : public Module