summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2021-01-11 10:07:11 +0000
committerSadie Powell <sadie@witchery.services>2021-01-11 10:07:11 +0000
commit5a19ff00aca5d979bf9ca45a2b0d6e85acdc9fc3 (patch)
tree3e5c31e168342671b38b77cab5eafe9b797bcc37 /src/modules
parent8d6b550e0b30983886dc240fd3261fae786d5693 (diff)
Add a user mode which allows disabling receiving channel history.
Closes #1830.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_chanhistory.cpp28
1 files changed, 22 insertions, 6 deletions
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<HistoryMode, SimpleExtItem<HistoryList> >
}
};
+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<Channel>();
- 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;