+ while (i != upperbound)
+ {
+ if (i->second.UserCommand)
+ {
+ if (DoAlias(user, NULL, &(i->second), compare, original_line))
+ {
+ return MOD_RES_DENY;
+ }
+ }
+
+ i++;
+ }
+
+ // If we made it here, no aliases actually matched.
+ return MOD_RES_PASSTHRU;
+ }
+
+ 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) || (msgtype != MSG_PRIVMSG))
+ {
+ return;
+ }
+
+ // fcommands are only for local users. Spanningtree will send them back out as their original cmd.
+ if (!IS_LOCAL(user))
+ {
+ return;
+ }
+
+ /* Stop here if the user is +B and allowbot is set to no. */
+ if (!AllowBots && user->IsModeSet(botmode))
+ {
+ return;
+ }
+
+ Channel *c = (Channel *)dest;
+ std::string scommand;
+
+ // text is like "!moo cows bite me", we want "!moo" first
+ irc::spacesepstream ss(text);
+ ss.GetToken(scommand);
+
+ if (scommand.empty())
+ {
+ return; // wtfbbq
+ }
+
+ // we don't want to touch non-fantasy stuff
+ if (*scommand.c_str() != fprefix)
+ {
+ return;
+ }
+
+ // nor do we give a shit about the prefix
+ scommand.erase(scommand.begin());
+
+ AliasMap::iterator i = Aliases.find(scommand);
+
+ if (i == Aliases.end())
+ return;
+
+ /* Avoid iterating on to other aliases if no patterns match */
+ AliasMap::iterator upperbound = Aliases.upper_bound(scommand);