X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_alias.cpp;h=1076b0a9a12c88d113b27648bc13510dcaba4071;hb=a2461fb7e1c28e28e64b61256d7a547162a83f6e;hp=9055a8bf829d23bde263771ecbe44533ed8bc6d4;hpb=f71e6bf9cb41811f18864f5d4eecb26e29d03f25;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 9055a8bf8..1076b0a9a 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -57,13 +57,13 @@ class Alias class ModuleAlias : public Module { - char fprefix; + std::string 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 */ - typedef std::multimap AliasMap; + typedef insp::flat_multimap AliasMap; AliasMap Aliases; @@ -76,8 +76,8 @@ class ModuleAlias : public Module { ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy"); AllowBots = fantasy->getBool("allowbots", false); - std::string fpre = fantasy->getString("prefix", "!"); - fprefix = fpre.empty() ? '!' : fpre[0]; + std::string fpre = fantasy->getString("prefix"); + fprefix = fpre.empty() ? "!" : fpre; Aliases.clear(); ConfigTagList tags = ServerInstance->Config->ConfTags("alias"); @@ -148,7 +148,7 @@ class ModuleAlias : public Module return MOD_RES_PASSTHRU; /* The parameters for the command in their original form, with the command stripped off */ - std::string compare = original_line.substr(command.length()); + std::string compare(original_line, command.length()); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); @@ -193,26 +193,26 @@ class ModuleAlias : public Module irc::spacesepstream ss(text); ss.GetToken(scommand); - if (scommand.empty()) + if (scommand.size() <= fprefix.size()) { return; // wtfbbq } // we don't want to touch non-fantasy stuff - if (*scommand.c_str() != fprefix) + if (scommand.compare(0, fprefix.size(), fprefix) != 0) { return; } // nor do we give a shit about the prefix - scommand.erase(scommand.begin()); + scommand.erase(0, fprefix.size()); std::pair iters = Aliases.equal_range(scommand); if (iters.first == iters.second) return; /* The parameters for the command in their original form, with the command stripped off */ - std::string compare = text.substr(scommand.length() + 1); + std::string compare(text, scommand.length() + fprefix.size()); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); @@ -220,8 +220,8 @@ class ModuleAlias : public Module { if (i->second.ChannelCommand) { - // We use substr(1) here to remove the fantasy prefix - if (DoAlias(user, c, &(i->second), compare, text.substr(1))) + // We use substr here to remove the fantasy prefix + if (DoAlias(user, c, &(i->second), compare, text.substr(fprefix.size()))) return; } } @@ -302,28 +302,28 @@ class ModuleAlias : public Module result.append(GetVar(var, original_line)); i += len - 1; } - else if (newline.substr(i, 5) == "$nick") + else if (!newline.compare(i, 5, "$nick", 5)) { result.append(user->nick); i += 4; } - else if (newline.substr(i, 5) == "$host") + else if (!newline.compare(i, 5, "$host", 5)) { result.append(user->host); i += 4; } - else if (newline.substr(i, 5) == "$chan") + else if (!newline.compare(i, 5, "$chan", 5)) { if (chan) result.append(chan->name); i += 4; } - else if (newline.substr(i, 6) == "$ident") + else if (!newline.compare(i, 6, "$ident", 6)) { result.append(user->ident); i += 5; } - else if (newline.substr(i, 6) == "$vhost") + else if (!newline.compare(i, 6, "$vhost", 6)) { result.append(user->dhost); i += 5; @@ -344,14 +344,14 @@ class ModuleAlias : public Module { pars.push_back(token); } - ServerInstance->Parser->CallHandler(command, pars, user); + ServerInstance->Parser.CallHandler(command, pars, user); } void Prioritize() { // Prioritise after spanningtree so that channel aliases show the alias before the effects. Module* linkmod = ServerInstance->Modules->Find("m_spanningtree.so"); - ServerInstance->Modules->SetPriority(this, I_OnUserMessage, PRIORITY_AFTER, &linkmod); + ServerInstance->Modules->SetPriority(this, I_OnUserMessage, PRIORITY_AFTER, linkmod); } };