summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-03-30 11:52:36 +0000
committerPeter Powell <petpow@saberuk.com>2019-03-30 11:52:36 +0000
commit180b8b6ab194fd74cb5c64fc3ec0775eb542451a (patch)
tree0f3af15f5bf23098e9725288ebfdef46018c9b8b
parent0b66cad1b04c104f3afb75cafd23faf4cb527a49 (diff)
Mark messages with inspircd.org/bot if the user has +B set.
-rw-r--r--src/modules/m_botmode.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp
index 1931666d1..1007f7ca1 100644
--- a/src/modules/m_botmode.cpp
+++ b/src/modules/m_botmode.cpp
@@ -20,6 +20,7 @@
#include "inspircd.h"
+#include "modules/cap.h"
#include "modules/whois.h"
enum
@@ -28,13 +29,44 @@ enum
RPL_WHOISBOT = 335
};
+class BotTag : public ClientProtocol::MessageTagProvider
+{
+ private:
+ SimpleUserModeHandler& botmode;
+ Cap::Reference ctctagcap;
+
+ public:
+ BotTag(Module* mod, SimpleUserModeHandler& bm)
+ : ClientProtocol::MessageTagProvider(mod)
+ , botmode(bm)
+ , ctctagcap(mod, "message-tags")
+ {
+ }
+
+ void OnClientProtocolPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE
+ {
+ User* const user = msg.GetSourceUser();
+ if (user && user->IsModeSet(botmode))
+ msg.AddTag("inspircd.org/bot", this, "");
+ }
+
+ bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) CXX11_OVERRIDE
+ {
+ return ctctagcap.get(user);
+ }
+};
+
class ModuleBotMode : public Module, public Whois::EventListener
{
+ private:
SimpleUserModeHandler bm;
+ BotTag tag;
+
public:
ModuleBotMode()
: Whois::EventListener(this)
, bm(this, "bot", 'B')
+ , tag(this, bm)
{
}