aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_botmode.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2019-03-30 22:06:19 +0000
committerGravatar Sadie Powell2019-03-30 22:06:19 +0000
commit1fff2f7f87fa0e69494fe45902cfa315204d1e43 (patch)
treeb4f3eac01dc458cc7f3ab5b43a57c44d06044bed /src/modules/m_botmode.cpp
parentRemove the flashpolicyd module. (diff)
parentRename OnClientProtocolPopulateTags to OnPopulateTags. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_botmode.cpp')
-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 1bb06e687..a86e9116f 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 OnPopulateTags(ClientProtocol::Message& msg) 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) 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)
{
}