Merge pull request #108 from CafogenMod/cloudev
implement a sed style correction method
This commit is contained in:
commit
1018481499
2 changed files with 20 additions and 1 deletions
19
plugins/correction.py
Normal file
19
plugins/correction.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from util import hook
|
||||||
|
import re
|
||||||
|
|
||||||
|
@hook.regex(r'^(s|S)/.*/.*/$')
|
||||||
|
def correction(inp, say=None, input=None, notice=None, db=None):
|
||||||
|
|
||||||
|
last_message = db.execute("select name, quote from seen_user where name"
|
||||||
|
" like ? and chan = ?", (input.nick.lower(), input.chan.lower())).fetchone()
|
||||||
|
|
||||||
|
if last_message:
|
||||||
|
splitinput = input.msg.split("/")
|
||||||
|
find = splitinput[1]
|
||||||
|
replace = splitinput[2]
|
||||||
|
if find in last_message[1]:
|
||||||
|
say("%s meant to say: %s" % (input.nick, last_message[1].replace(find, replace)))
|
||||||
|
else:
|
||||||
|
notice("%s can't be found in your last message" % find)
|
||||||
|
else:
|
||||||
|
notice("I haven't seen you say anything here yet")
|
|
@ -22,7 +22,7 @@ def seen_sieve(paraml, input=None, db=None, bot=None):
|
||||||
if not db_ready:
|
if not db_ready:
|
||||||
db_init(db)
|
db_init(db)
|
||||||
# keep private messages private
|
# keep private messages private
|
||||||
if input.chan[:1] == "#":
|
if input.chan[:1] == "#" and not re.findall('^s/.*/.*/$', input.msg.lower()):
|
||||||
db.execute("insert or replace into seen_user(name, time, quote, chan, host)"
|
db.execute("insert or replace into seen_user(name, time, quote, chan, host)"
|
||||||
"values(?,?,?,?,?)", (input.nick.lower(), time.time(), input.msg,
|
"values(?,?,?,?,?)", (input.nick.lower(), time.time(), input.msg,
|
||||||
input.chan, input.mask))
|
input.chan, input.mask))
|
||||||
|
|
Reference in a new issue