tweaked new correction code
This commit is contained in:
parent
d834ae9070
commit
10907bf214
1 changed files with 5 additions and 6 deletions
|
@ -5,7 +5,7 @@ import re
|
||||||
CORRECTION_RE = re.compile(r'^(s|S)/.*/.*/\S*$')
|
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):
|
def correction(inp, input=None, bot=None, message=None):
|
||||||
split = input.msg.split("/")
|
split = input.msg.split("/")
|
||||||
|
|
||||||
|
@ -14,8 +14,7 @@ def correction(inp, input=None, bot=None, message=None):
|
||||||
|
|
||||||
for item in bot.history[input.chan].__reversed__():
|
for item in bot.history[input.chan].__reversed__():
|
||||||
name, timestamp, msg = item
|
name, timestamp, msg = item
|
||||||
if "/" in msg:
|
if msg.startswith("s/"):
|
||||||
if re.match(CORRECTION_RE, msg):
|
|
||||||
# don't correct corrections, it gets really confusing
|
# don't correct corrections, it gets really confusing
|
||||||
continue
|
continue
|
||||||
if find in msg:
|
if find in msg:
|
||||||
|
@ -26,5 +25,5 @@ def correction(inp, input=None, bot=None, message=None):
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return "Did not find {} in any recent messages.".format(find)
|
return u"Did not find {} in any recent messages.".format(find)
|
||||||
|
|
||||||
|
|
Reference in a new issue