1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 06:36:39 +02:00

Strip color codes when looking up fantasy commands.

This commit is contained in:
Adam
2015-03-11 09:16:32 -04:00
parent fb17bc85ea
commit a899c04ec2
+22 -6
View File
@@ -103,12 +103,28 @@ class Fantasy : public Module
std::vector<Anope::string> params;
spacesepstream(msg).GetTokens(params);
if (!msg.find(c->ci->bi->nick))
params.erase(params.begin());
else if (!msg.find_first_of(Config->GetModule(this)->Get<const Anope::string>("fantasycharacter", "!")))
params[0].erase(params[0].begin());
else
if (params.empty())
return;
Anope::string normalized_param0 = Anope::NormalizeBuffer(params[0]);
Anope::string fantasy_chars = Config->GetModule(this)->Get<Anope::string>("fantasycharacter", "!");
if (!normalized_param0.find(c->ci->bi->nick))
{
params.erase(params.begin());
}
else if (!normalized_param0.find_first_of(fantasy_chars))
{
size_t sz = params[0].find_first_of(fantasy_chars);
if (sz == Anope::string::npos)
return; /* normalized_param0 is a subset of params[0] so this can't happen */
params[0].erase(0, sz + 1);
}
else
{
return;
}
if (params.empty())
return;
@@ -123,7 +139,7 @@ class Fantasy : public Module
full_command.erase(full_command.begin());
++count;
it = Config->Fantasy.find(full_command);
it = Config->Fantasy.find(Anope::NormalizeBuffer(full_command));
}
if (it == Config->Fantasy.end())