From 70a92b4daee9f2fb91c9b5831c1e17d523c34e09 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 22 Sep 2024 14:01:37 +0100 Subject: [PATCH] Allow opting-out of saving bot messages in the channel history. Closes #2107. --- docs/conf/modules.example.conf | 4 ++++ src/modules/m_chanhistory.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/docs/conf/modules.example.conf b/docs/conf/modules.example.conf index c696550f0..9f311873f 100644 --- a/docs/conf/modules.example.conf +++ b/docs/conf/modules.example.conf @@ -322,12 +322,16 @@ # don't support the chathistory batch type. Defaults to # # yes. # # # +# savefrombots - Whether to save messages from users with user mode # +# +B (bot) in the channel history. Defaults to yes. # +# # # sendtobots - Whether to send channel history to users with user # # mode +B (bot) enabled. Defaults to yes. # # # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index 080e202f3..290a8b2de 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -173,6 +173,7 @@ private: IRCv3::ServerTime::API servertimemanager; ClientProtocol::MessageTagEvent tagevent; bool prefixmsg; + bool savefrombots; bool sendtobots; void AddTag(ClientProtocol::Message& msg, const std::string& tagkey, std::string& tagval) @@ -232,6 +233,7 @@ public: historymode.maxduration = tag->getDuration("maxduration", 60*60*24*28); historymode.maxlines = tag->getNum("maxlines", 50); prefixmsg = tag->getBool("prefixmsg", true); + savefrombots = tag->getBool("savefrombots", true); sendtobots = tag->getBool("sendtobots", tag->getBool("bots", true)); } @@ -245,6 +247,9 @@ public: if (target.type != MessageTarget::TYPE_CHANNEL || target.status) return; + if (user->IsModeSet(botmode) && !savefrombots) + return; + std::string_view ctcpname; if (details.IsCTCP(ctcpname) && !irc::equals(ctcpname, "ACTION")) return;