tweaked new correction code

This commit is contained in:
Luke Rogers 2014-02-28 19:48:46 +13:00
parent d834ae9070
commit 10907bf214
1 changed files with 5 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import re
CORRECTION_RE = re.compile(r'^(s|S)/.*/.*/\S*$')
@hook.regex(r'^(s|S)/.*/.*/\S*$')
@hook.regex(CORRECTION_RE)
def correction(inp, input=None, bot=None, message=None):
split = input.msg.split("/")
@ -14,10 +14,9 @@ def correction(inp, input=None, bot=None, message=None):
for item in bot.history[input.chan].__reversed__():
name, timestamp, msg = item
if "/" in msg:
if re.match(CORRECTION_RE, msg):
# don't correct corrections, it gets really confusing
continue
if msg.startswith("s/"):
# don't correct corrections, it gets really confusing
continue
if find in msg:
if "\x01ACTION" in msg:
msg = msg.replace("\x01ACTION ", "/me ").replace("\x01", "")
@ -26,5 +25,5 @@ def correction(inp, input=None, bot=None, message=None):
else:
continue
return "Did not find {} in any recent messages.".format(find)
return u"Did not find {} in any recent messages.".format(find)