]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_botmode.cpp
Fix cloaking not ignoring the case of a user's hostname.
[user/henk/code/inspircd.git] / src / modules / m_botmode.cpp
index 1931666d1527997f9ab1394596b8485975ff73e0..44241e82c5e83151391bb48a33cba37865f50a77 100644 (file)
@@ -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) 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)
        {
        }