X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_alias.cpp;h=b0fda70bbdbe16b23f1b0964b0ad64c41ecf2b26;hb=a98d2f5086f3ac27f5d311cb0ac5307dce85ed4f;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..b0fda70bb 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,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 @@ -175,9 +172,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 +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; } @@ -244,7 +241,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; @@ -271,7 +268,7 @@ class ModuleAlias : public Module u = ServerInstance->FindNick(a->RequiredNick); if (!u) { - user->WriteNumeric(401, ""+user->nick+" "+a->RequiredNick+" :is currently unavailable. Please try again later."); + user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is currently unavailable. Please try again later."); return 1; } } @@ -280,7 +277,7 @@ class ModuleAlias : public Module if (!ServerInstance->ULine(u->server)) { ServerInstance->SNO->WriteToSnoMask('a', "NOTICE -- Service "+a->RequiredNick+" required by alias "+std::string(a->AliasedCommand.c_str())+" is not on a u-lined server, possibly underhanded antics detected!"); - user->WriteNumeric(401, ""+user->nick+" "+a->RequiredNick+" :is an imposter! Please inform an IRC operator as soon as possible."); + user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is an imposter! Please inform an IRC operator as soon as possible."); return 1; } } @@ -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(MAXBUF); + result.reserve(newline.length()); for (unsigned int i = 0; i < newline.length(); i++) { char c = newline[i]; @@ -360,18 +357,13 @@ 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); } - void OnRehash(User* user) CXX11_OVERRIDE - { - ReadAliases(); - } - void Prioritize() { // Prioritise after spanningtree so that channel aliases show the alias before the effects.