Improved correction some more
This commit is contained in:
parent
8340f55adf
commit
f05a35dd96
1 changed files with 10 additions and 2 deletions
|
@ -2,13 +2,18 @@ from util import hook
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
CORRECTION_RE = r'^(s|S)/.*/.*/\S*$'
|
CORRECTION_RE = r'^(s|S)/.*/.*/?\S*$'
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(CORRECTION_RE)
|
@hook.regex(CORRECTION_RE)
|
||||||
def correction(inp, input=None, bot=None, message=None):
|
def correction(match, input=None, bot=None, message=None):
|
||||||
split = input.msg.split("/")
|
split = input.msg.split("/")
|
||||||
|
|
||||||
|
if len(split) == 4:
|
||||||
|
nick = split[3].lower()
|
||||||
|
else:
|
||||||
|
nick = None
|
||||||
|
|
||||||
find = split[1]
|
find = split[1]
|
||||||
replace = split[2]
|
replace = split[2]
|
||||||
|
|
||||||
|
@ -17,6 +22,9 @@ def correction(inp, input=None, bot=None, message=None):
|
||||||
if msg.startswith("s/"):
|
if msg.startswith("s/"):
|
||||||
# don't correct corrections, it gets really confusing
|
# don't correct corrections, it gets really confusing
|
||||||
continue
|
continue
|
||||||
|
if nick:
|
||||||
|
if nick != name.lower():
|
||||||
|
continue
|
||||||
if find in msg:
|
if find in msg:
|
||||||
if "\x01ACTION" in msg:
|
if "\x01ACTION" in msg:
|
||||||
msg = msg.replace("\x01ACTION ", "/me ").replace("\x01", "")
|
msg = msg.replace("\x01ACTION ", "/me ").replace("\x01", "")
|
||||||
|
|
Reference in a new issue