]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/ctctags.h
Use IsCTCP in blockcolor for ignoring CTCPs.
[user/henk/code/inspircd.git] / include / modules / ctctags.h
index d8798de548f84262691f097cc19dba2879899710..5f102b5d725e415f913abbf6894169c9831538c1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
+ *   Copyright (C) 2018, 2020 Sadie Powell <sadie@witchery.services>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
 #pragma once
 
 #include "event.h"
+#include "modules/cap.h"
 
 namespace CTCTags
 {
+       class CapReference;
        class EventListener;
        class TagMessage;
        class TagMessageDetails;
 }
 
+class CTCTags::CapReference : public Cap::Reference
+{
+ public:
+       CapReference(Module* mod)
+               : Cap::Reference(mod, "message-tags")
+       {
+       }
+};
+
 class CTCTags::TagMessage : public ClientProtocol::Message
 {
+private:
+       void PushTarget(const char* target, char status)
+       {
+               if (status)
+               {
+                       std::string rawtarget(1, status);
+                       rawtarget.append(target);
+                       PushParam(rawtarget);
+               }
+               else
+                       PushParam(target);
+       }
+
  public:
-       TagMessage(User* source, const Channel* targetchan, const ClientProtocol::TagMap& Tags)
+       TagMessage(User* source, const Channel* targetchan, const ClientProtocol::TagMap& Tags, char status = 0)
                : ClientProtocol::Message("TAGMSG", source)
        {
-               PushParamRef(targetchan->name);
+               PushTarget(targetchan->name.c_str(), status);
                AddTags(Tags);
-               SetSideEffect(true);
        }
 
        TagMessage(User* source, const User* targetuser, const ClientProtocol::TagMap& Tags)
@@ -47,15 +70,20 @@ class CTCTags::TagMessage : public ClientProtocol::Message
                else
                        PushParam("*");
                AddTags(Tags);
-               SetSideEffect(true);
        }
 
-       TagMessage(User* source, const char* targetstr, const ClientProtocol::TagMap& Tags)
+       TagMessage(User* source, const char* targetstr, const ClientProtocol::TagMap& Tags, char status = 0)
+               : ClientProtocol::Message("TAGMSG", source)
+       {
+               PushTarget(targetstr, status);
+               AddTags(Tags);
+       }
+
+       TagMessage(const char* source, const char* targetstr, const ClientProtocol::TagMap& Tags, char status = 0)
                : ClientProtocol::Message("TAGMSG", source)
        {
-               PushParam(targetstr);
+               PushTarget(targetstr, status);
                AddTags(Tags);
-               SetSideEffect(true);
        }
 };
 
@@ -68,6 +96,9 @@ class CTCTags::TagMessageDetails
        /* Whether to send the original tags back to clients with echo-message support. */
        bool echo_original;
 
+       /** Whether to update the source user's idle time. */
+       bool update_idle;
+
        /** The users who are exempted from receiving this message. */
        CUList exemptions;
 
@@ -80,6 +111,7 @@ class CTCTags::TagMessageDetails
        TagMessageDetails(const ClientProtocol::TagMap& tags)
                : echo(true)
                , echo_original(false)
+               , update_idle(true)
                , tags_in(tags)
        {
        }
@@ -105,7 +137,7 @@ class CTCTags::EventListener
         *         message, or MOD_RES_PASSTHRU to let another module handle the event.
         */
        virtual ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, TagMessageDetails& details) { return MOD_RES_PASSTHRU; }
-       
+
        /** Called immediately after a user sends a tag message to a channel, a user, or a server glob mask.
         * @param user The user sending the message.
         * @param target The target of the message. This can either be a channel, a user, or a server