]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_alias.cpp
m_spanningtree Remove SpanningTreeUtilities* fields and parameters
[user/henk/code/inspircd.git] / src / modules / m_alias.cpp
index 97b1612afe308d8e4d955d97e739ce38e0ca5cc0..4d942854cbdeff85c5aa5dd2093a205a1ea37643 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides aliases of commands. */
-
 /** An alias definition
  */
 class Alias
@@ -59,20 +57,19 @@ class Alias
 
 class ModuleAlias : public Module
 {
- private:
-
        char fprefix;
 
        /* We cant use a map, there may be multiple aliases with the same name.
         * We can, however, use a fancy invention: the multimap. Maps a key to one or more values.
         *              -- w00t
-   */
+     */
        std::multimap<irc::string, Alias> Aliases;
 
        /* whether or not +B users are allowed to use fantasy commands */
        bool AllowBots;
+       UserModeReference botmode;
 
-       virtual void ReadAliases()
+       void ReadAliases()
        {
                ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy");
                AllowBots = fantasy->getBool("allowbots", false);
@@ -100,19 +97,17 @@ class ModuleAlias : public Module
        }
 
  public:
-
-       void init()
+       ModuleAlias()
+               : botmode(this, "bot")
        {
-               ReadAliases();
-               Implementation eventlist[] = { I_OnPreCommand, I_OnRehash, I_OnUserMessage };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       virtual ~ModuleAlias()
+       void init() CXX11_OVERRIDE
        {
+               ReadAliases();
        }
 
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides aliases of commands.", VF_VENDOR);
        }
@@ -142,7 +137,7 @@ class ModuleAlias : public Module
                return word;
        }
 
-       virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
+       ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE
        {
                std::multimap<irc::string, Alias>::iterator i, upperbound;
 
@@ -182,9 +177,9 @@ class ModuleAlias : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       virtual void OnUserMessage(User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list)
+       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;
                }
@@ -196,7 +191,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;
                }
@@ -251,7 +246,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;
 
@@ -270,7 +265,7 @@ class ModuleAlias : public Module
                        }
                }
 
-               if ((a->OperOnly) && (!IS_OPER(user)))
+               if ((a->OperOnly) && (!user->IsOper()))
                        return 0;
 
                if (!a->RequiredNick.empty())
@@ -316,7 +311,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];
@@ -367,19 +362,19 @@ 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);
                }
                ServerInstance->Parser->CallHandler(command, pars, user);
        }
 
-       virtual void OnRehash(User* user)
+       void OnRehash(User* user) CXX11_OVERRIDE
        {
                ReadAliases();
        }
 
-       virtual void Prioritize()
+       void Prioritize()
        {
                // Prioritise after spanningtree so that channel aliases show the alias before the effects.
                Module* linkmod = ServerInstance->Modules->Find("m_spanningtree.so");