]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_alias.cpp
Replace OnRehash() with ReadConfig() that is called on boot, on module load and on...
[user/henk/code/inspircd.git] / src / modules / m_alias.cpp
index 7e15b8c04a52b395abd4e10f226ac499a81762ca..7d2eabd15dfd467bb9aaa509e1a2277ee7e5e5cb 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides aliases of commands. */
-
 /** An alias definition
  */
 class Alias
@@ -69,8 +67,10 @@ class ModuleAlias : public Module
 
        /* whether or not +B users are allowed to use fantasy commands */
        bool AllowBots;
+       UserModeReference botmode;
 
-       void ReadAliases()
+ public:
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy");
                AllowBots = fantasy->getBool("allowbots", false);
@@ -97,12 +97,9 @@ class ModuleAlias : public Module
                }
        }
 
- public:
-       void init() CXX11_OVERRIDE
+       ModuleAlias()
+               : botmode(this, "bot")
        {
-               ReadAliases();
-               Implementation eventlist[] = { I_OnPreCommand, I_OnRehash, I_OnUserMessage };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        Version GetVersion() CXX11_OVERRIDE
@@ -189,7 +186,7 @@ class ModuleAlias : public Module
                }
 
                /* Stop here if the user is +B and allowbot is set to no. */
-               if (!AllowBots && user->IsModeSet('B'))
+               if (!AllowBots && user->IsModeSet(botmode))
                {
                        return;
                }
@@ -309,7 +306,7 @@ class ModuleAlias : public Module
        void DoCommand(const std::string& newline, User* user, Channel *chan, const std::string &original_line)
        {
                std::string result;
-               result.reserve(ServerInstance->Config->Limits.MaxLine);
+               result.reserve(newline.length());
                for (unsigned int i = 0; i < newline.length(); i++)
                {
                        char c = newline[i];
@@ -367,11 +364,6 @@ class ModuleAlias : public Module
                ServerInstance->Parser->CallHandler(command, pars, user);
        }
 
-       void OnRehash(User* user) CXX11_OVERRIDE
-       {
-               ReadAliases();
-       }
-
        void Prioritize()
        {
                // Prioritise after spanningtree so that channel aliases show the alias before the effects.