X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_alias.cpp;h=73e3bfd46e682b98dba17006cc74077df42a26ce;hb=fd1d19d6345943ecdb5ce4ef947f9b3c5c8bca86;hp=b08f720115dd6b442592a0f6b1b5be9829cd01a1;hpb=4b41feea830fc84e8c1b2fd0982f3e8d8840af96;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index b08f72011..73e3bfd46 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -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); }