]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_alias.cpp
Replace hardcoded mode letters, part 3
[user/henk/code/inspircd.git] / src / modules / m_alias.cpp
index b08f720115dd6b442592a0f6b1b5be9829cd01a1..73e3bfd46e682b98dba17006cc74077df42a26ce 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides aliases of commands. */
-
 /** An alias definition
  */
 class Alias
@@ -69,6 +67,7 @@ class ModuleAlias : public Module
 
        /* whether or not +B users are allowed to use fantasy commands */
        bool AllowBots;
+       UserModeReference botmode;
 
        void ReadAliases()
        {
@@ -98,6 +97,11 @@ class ModuleAlias : public Module
        }
 
  public:
+       ModuleAlias()
+               : botmode(this, "bot")
+       {
+       }
+
        void init() CXX11_OVERRIDE
        {
                ReadAliases();
@@ -175,9 +179,9 @@ class ModuleAlias : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       void OnUserMessage(User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list) CXX11_OVERRIDE
+       void OnUserMessage(User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list, MessageType msgtype) CXX11_OVERRIDE
        {
-               if (target_type != TYPE_CHANNEL)
+               if ((target_type != TYPE_CHANNEL) || (msgtype != MSG_PRIVMSG))
                {
                        return;
                }
@@ -189,7 +193,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;
                }
@@ -244,7 +248,7 @@ class ModuleAlias : public Module
        }
 
 
-       int DoAlias(User *user, Channel *c, Alias *a, const std::string compare, const std::string safe)
+       int DoAlias(User *user, Channel *c, Alias *a, const std::string& compare, const std::string& safe)
        {
                User *u = NULL;
 
@@ -309,7 +313,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(MAXBUF);
+               result.reserve(newline.length());
                for (unsigned int i = 0; i < newline.length(); i++)
                {
                        char c = newline[i];
@@ -360,7 +364,7 @@ class ModuleAlias : public Module
                std::string command, token;
 
                ss.GetToken(command);
-               while (ss.GetToken(token) && (pars.size() <= MAXPARAMETERS))
+               while (ss.GetToken(token))
                {
                        pars.push_back(token);
                }