]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chanhistory.cpp
m_operjoin Remove duplicated code
[user/henk/code/inspircd.git] / src / modules / m_chanhistory.cpp
index c114891bb80904a598481c1f0d8df1600362372c..24c6237b3812b6d7e9a18426d2563381ef6c4944 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides channel history for a given number of lines */
-
 struct HistoryItem
 {
        time_t ts;
@@ -94,14 +92,12 @@ class HistoryMode : public ModeHandler
                        {
                                ext.set(channel, new HistoryList(len, time));
                        }
-                       channel->SetModeParam('H', parameter);
                }
                else
                {
-                       if (!channel->IsModeSet('H'))
+                       if (!channel->IsModeSet(this))
                                return MODEACTION_DENY;
                        ext.unset(channel);
-                       channel->SetModeParam('H', "");
                }
                return MODEACTION_ALLOW;
        }
@@ -111,26 +107,19 @@ class ModuleChanHistory : public Module
 {
        HistoryMode m;
        bool sendnotice;
+       UserModeReference botmode;
+       bool dobots;
  public:
-       ModuleChanHistory() : m(this)
+       ModuleChanHistory() : m(this), botmode(this, "bot")
        {
        }
 
-       void init() CXX11_OVERRIDE
-       {
-               ServerInstance->Modules->AddService(m);
-               ServerInstance->Modules->AddService(m.ext);
-
-               Implementation eventlist[] = { I_OnPostJoin, I_OnUserMessage, I_OnRehash };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-               OnRehash(NULL);
-       }
-
-       void OnRehash(User*) CXX11_OVERRIDE
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory");
                m.maxlines = tag->getInt("maxlines", 50);
                sendnotice = tag->getBool("notice", true);
+               dobots = tag->getBool("bots", true);
        }
 
        void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList&, MessageType msgtype) CXX11_OVERRIDE
@@ -154,6 +143,9 @@ class ModuleChanHistory : public Module
                if (IS_REMOTE(memb->user))
                        return;
 
+               if (memb->user->IsModeSet(botmode) && !dobots)
+                       return;
+
                HistoryList* list = m.ext.get(memb->chan);
                if (!list)
                        return;