summaryrefslogtreecommitdiff
path: root/modules/fantasy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/fantasy.cpp')
-rw-r--r--modules/fantasy.cpp24
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())