Merge pull request #110 from cybojenix/patch-5
add in option to correct other people's mistakes
This commit is contained in:
commit
af4bcdb621
1 changed files with 12 additions and 4 deletions
|
@ -1,19 +1,27 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@hook.regex(r'^(s|S)/.*/.*/$')
|
@hook.regex(r'^(s|S)/.*/.*/\S*$')
|
||||||
def correction(inp, say=None, input=None, notice=None, db=None):
|
def correction(inp, say=None, input=None, notice=None, db=None):
|
||||||
|
|
||||||
|
splitinput = input.msg.split("/")
|
||||||
|
if splitinput[3]:
|
||||||
|
nick = splitinput[3]
|
||||||
|
else:
|
||||||
|
nick = input.nick
|
||||||
last_message = db.execute("select name, quote from seen_user where name"
|
last_message = db.execute("select name, quote from seen_user where name"
|
||||||
" like ? and chan = ?", (input.nick.lower(), input.chan.lower())).fetchone()
|
" like ? and chan = ?", (nick.lower(), input.chan.lower())).fetchone()
|
||||||
|
|
||||||
if last_message:
|
if last_message:
|
||||||
splitinput = input.msg.split("/")
|
splitinput = input.msg.split("/")
|
||||||
find = splitinput[1]
|
find = splitinput[1]
|
||||||
replace = splitinput[2]
|
replace = splitinput[2]
|
||||||
if find in last_message[1]:
|
if find in last_message[1]:
|
||||||
say("%s meant to say: %s" % (input.nick, last_message[1].replace(find, replace)))
|
say("%s meant to say: %s" % (nick, last_message[1].replace(find, replace)))
|
||||||
else:
|
else:
|
||||||
notice("%s can't be found in your last message" % find)
|
notice("%s can't be found in your last message" % find)
|
||||||
else:
|
else:
|
||||||
notice("I haven't seen you say anything here yet")
|
if nick = input.nick:
|
||||||
|
notice("I haven't seen you say anything here yet")
|
||||||
|
else:
|
||||||
|
notice("I haven't seen %s say anything here yet" % nick)
|
||||||
|
|
Reference in a new issue