diff options
author | Adam <Adam@anope.org> | 2015-03-11 09:16:32 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-03-11 09:16:32 -0400 |
commit | a899c04ec20bb85a0af994c3e7dfd80686cbef2b (patch) | |
tree | 0b4a9dcbe220c9669630c4d41f8046a2d8a44e27 | |
parent | fb17bc85ead8c1be6ebe1561f77865f083fdc000 (diff) |
Strip color codes when looking up fantasy commands.
-rw-r--r-- | modules/fantasy.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/modules/fantasy.cpp b/modules/fantasy.cpp index 58226699c..1bda6c106 100644 --- a/modules/fantasy.cpp +++ b/modules/fantasy.cpp @@ -103,12 +103,28 @@ class Fantasy : public Module std::vector<Anope::string> params; spacesepstream(msg).GetTokens(params); - if (!msg.find(c->ci->bi->nick)) + 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 (!msg.find_first_of(Config->GetModule(this)->Get<const Anope::string>("fantasycharacter", "!"))) - params[0].erase(params[0].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()) |