summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules/ircv3.h1
-rw-r--r--src/modules/m_ircv3_servertime.cpp16
2 files changed, 16 insertions, 1 deletions
diff --git a/include/modules/ircv3.h b/include/modules/ircv3.h
index ce2b70da7..3e58eb102 100644
--- a/include/modules/ircv3.h
+++ b/include/modules/ircv3.h
@@ -67,6 +67,7 @@ class IRCv3::WriteNeighborsWithCap : public User::ForEachNeighborHandler
template <typename T>
class IRCv3::CapTag : public ClientProtocol::MessageTagProvider
{
+ protected:
Cap::Capability cap;
const std::string tagname;
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