correction: update to use the seen_user db
This commit is contained in:
parent
d3429f3297
commit
3204d15bde
2 changed files with 2 additions and 24 deletions
|
@ -1,32 +1,10 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import re
|
import re
|
||||||
|
|
||||||
db_ready=False
|
|
||||||
|
|
||||||
# from seen.py
|
|
||||||
def db_init(db):
|
|
||||||
"check to see that our db has the the correction table and return a connection."
|
|
||||||
db.execute("create table if not exists correct_user(name, quote, chan, "
|
|
||||||
"primary key(name, chan))")
|
|
||||||
db.commit()
|
|
||||||
db_ready = True
|
|
||||||
|
|
||||||
@hook.singlethread
|
|
||||||
@hook.event('PRIVMSG')
|
|
||||||
def message_sieve(paraml, input=None, db=None, bot=None):
|
|
||||||
if not db_ready:
|
|
||||||
db_init(db)
|
|
||||||
if not re.findall('^s/.*/.*/$', input.msg.lower()):
|
|
||||||
db.execute("insert or replace into correct_user(name, quote, chan)"
|
|
||||||
"values(?,?,?)", (input.nick.lower(), input.msg, input.chan.lower()))
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
@hook.regex(r'^(s|S)/.*/.*/$')
|
@hook.regex(r'^(s|S)/.*/.*/$')
|
||||||
def correction(inp, say=None, input=None, notice=None, db=None):
|
def correction(inp, say=None, input=None, notice=None, db=None):
|
||||||
if not db_ready:
|
|
||||||
db_init(db)
|
|
||||||
|
|
||||||
last_message = db.execute("select name, quote from correct_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 = ?", (input.nick.lower(), input.chan.lower())).fetchone()
|
||||||
|
|
||||||
if last_message:
|
if last_message:
|
||||||
|
|
|
@ -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