From 5a19ff00aca5d979bf9ca45a2b0d6e85acdc9fc3 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 11 Jan 2021 10:07:11 +0000 Subject: Add a user mode which allows disabling receiving channel history. Closes #1830. --- src/modules/m_chanhistory.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index f689b292c..4bd230a7c 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -124,12 +124,24 @@ class HistoryMode : public ParamMode > } }; +class NoHistoryMode : public SimpleUserModeHandler +{ +public: + NoHistoryMode(Module* Creator) + : SimpleUserModeHandler(Creator, "nohistory", 'N') + { + if (!ServerInstance->Config->ConfValue("chanhistory")->getBool("enableumode")) + DisableAutoRegister(); + } +}; + class ModuleChanHistory : public Module , public ServerProtocol::BroadcastEventListener { private: - HistoryMode m; + HistoryMode historymode; + NoHistoryMode nohistorymode; bool prefixmsg; UserModeReference botmode; bool dobots; @@ -183,7 +195,8 @@ class ModuleChanHistory public: ModuleChanHistory() : ServerProtocol::BroadcastEventListener(this) - , m(this) + , historymode(this) + , nohistorymode(this) , botmode(this, "bot") , batchcap(this) , batchmanager(this) @@ -196,14 +209,14 @@ class ModuleChanHistory void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory"); - m.maxlines = tag->getUInt("maxlines", 50, 1); + historymode.maxlines = tag->getUInt("maxlines", 50, 1); prefixmsg = tag->getBool("prefixmsg", tag->getBool("notice", true)); dobots = tag->getBool("bots", true); } ModResult OnBroadcastMessage(Channel* channel, const Server* server) CXX11_OVERRIDE { - return channel->IsModeSet(m) ? MOD_RES_ALLOW : MOD_RES_PASSTHRU; + return channel->IsModeSet(historymode) ? MOD_RES_ALLOW : MOD_RES_PASSTHRU; } void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE @@ -212,7 +225,7 @@ class ModuleChanHistory if ((target.type == MessageTarget::TYPE_CHANNEL) && (target.status == 0) && (!details.IsCTCP(ctcpname) || irc::equals(ctcpname, "ACTION"))) { Channel* c = target.Get(); - HistoryList* list = m.ext.get(c); + HistoryList* list = historymode.ext.get(c); if (list) { list->lines.push_back(HistoryItem(user, details)); @@ -231,7 +244,10 @@ class ModuleChanHistory if (memb->user->IsModeSet(botmode) && !dobots) return; - HistoryList* list = m.ext.get(memb->chan); + if (memb->user->IsModeSet(nohistorymode)) + return; + + HistoryList* list = historymode.ext.get(memb->chan); if (!list) return; -- cgit v1.3.1-10-gc9f91 From 56b4dc61e49e4218544f51ac9a25ab3ece60a782 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 13 Jan 2021 00:05:17 +0000 Subject: Add a shun option to only apply when users are fully connected. Closes #1825. --- docs/conf/modules.conf.example | 4 ++++ src/modules/m_shun.cpp | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'src/modules') diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 1faec808c..0a85ef5ca 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -2185,6 +2185,9 @@ # option is deprecated; you should instead give exempt # server operators the servers/ignore-shun privilege. # +# allowconnect: Whether to only apply shuns to users who are fully +# connected to the server. +# # allowtags: Whether to allow client tags to be attached to enabled # commands. # @@ -2201,6 +2204,7 @@ # diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 1c64fd76c..d067d1523 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -156,11 +156,16 @@ class ModuleShun : public Module, public Stats::EventListener insp::flat_set cleanedcommands; insp::flat_set enabledcommands; bool affectopers; + bool allowconnect; bool allowtags; bool notifyuser; bool IsShunned(LocalUser* user) { + // Exempt the user if they are not fully connected and allowconnect is enabled. + if (allowconnect && user->registered != REG_ALL) + return false; + // Exempt the user from shuns if they are an oper and affectopers is disabled. if (!affectopers && user->IsOper()) return false; @@ -222,6 +227,7 @@ class ModuleShun : public Module, public Stats::EventListener affectopers = tag->getBool("affectopers", false); allowtags = tag->getBool("allowtags"); + allowconnect = tag->getBool("allowconnect"); notifyuser = tag->getBool("notifyuser", true); } -- cgit v1.3.1-10-gc9f91