Allow opting-out of saving bot messages in the channel history.

Closes #2107.
This commit is contained in:
Sadie Powell 2024-09-22 14:01:37 +01:00
parent 2b10b8fc2a
commit 70a92b4dae
2 changed files with 9 additions and 0 deletions

View File

@ -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. #
#
#<chanhistory maxlines="50"
# maxduration="4w"
# prefixmsg="yes"
# savefrombots="yes"
# sendtobots="yes">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

View File

@ -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<unsigned long>("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;