From 4cd71d12efde0c0c70922e57d5ab72d8d37c50a7 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 28 Mar 2017 22:00:41 -0700 Subject: [PATCH] fantasy: don't trigger when the fantasy prefix is followed by a space This prevents false positives such as "& that", "@ person", etc. --- plugins/fantasy.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/fantasy.py b/plugins/fantasy.py index edd2ff5..fdd96f6 100644 --- a/plugins/fantasy.py +++ b/plugins/fantasy.py @@ -44,8 +44,9 @@ def handle_fantasy(irc, source, command, args): # to the prefix list: "," and ":" nick = irc.toLower(irc.users[servuid].nick) + nick_prefixes = [nick+',', nick+':'] if respondtonick: - prefixes += [nick+',', nick+':'] + prefixes += nick_prefixes if not any(prefixes): # No prefixes were set, so skip. @@ -58,6 +59,13 @@ def handle_fantasy(irc, source, command, args): # Cut off the length of the prefix from the text. text = orig_text[len(prefix):] + # HACK: don't trigger on commands like "& help" to prevent false positives. + # Weird spacing like "PyLink: help" and "/msg PyLink help" should still + # work though. + if text.startswith(' ') and prefix not in nick_prefixes: + log.debug('(%s) fantasy: skipping trigger with text prefix followed by space', irc.name) + continue + # Finally, call the bot command and loop to the next bot. sbot.call_cmd(irc, source, text, called_in=channel) continue