+
+ if (batchmanager)
+ batchmanager->End(batch);
+ }
+
+ public:
+ ModuleChanHistory()
+ : ServerProtocol::BroadcastEventListener(this)
+ , historymode(this)
+ , nohistorymode(this)
+ , botmode(this, "bot")
+ , batchcap(this)
+ , batchmanager(this)
+ , batch("chathistory")
+ , servertimemanager(this)
+ , tagevent(this)
+ {
+ }
+
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+ {
+ ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory");
+ 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(historymode) ? MOD_RES_ALLOW : MOD_RES_PASSTHRU;
+ }
+
+ void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE
+ {
+ if (target.type != MessageTarget::TYPE_CHANNEL || target.status)
+ return;
+
+ std::string ctcpname;
+ if (details.IsCTCP(ctcpname) && !irc::equals(ctcpname, "ACTION"))
+ return;
+
+ HistoryList* list = historymode.ext.get(target.Get<Channel>());
+ if (!list)
+ return;
+
+ list->lines.push_back(HistoryItem(user, details));
+ if (list->lines.size() > list->maxlen)
+ list->lines.pop_front();