further DB work
This commit is contained in:
parent
2ebb30d2d7
commit
99487b66c6
|
@ -64,6 +64,7 @@ def run(bot, func, input):
|
|||
if args:
|
||||
if uses_db:
|
||||
# create SQLAlchemy session
|
||||
bot.logger.debug("Opened DB session for: {}".format(func._filename))
|
||||
input.db = input.bot.db_session()
|
||||
if 'input' in args:
|
||||
input.input = input
|
||||
|
@ -86,7 +87,7 @@ def run(bot, func, input):
|
|||
return
|
||||
finally:
|
||||
if uses_db:
|
||||
print "Close"
|
||||
bot.logger.debug("Closed DB session for: {}".format(func._filename))
|
||||
input.db.close()
|
||||
else:
|
||||
try:
|
||||
|
@ -124,6 +125,7 @@ class Handler(object):
|
|||
break
|
||||
|
||||
if uses_db:
|
||||
# self.bot.logger.debug("Opened ST DB session for: {}".format(self.func._filename))
|
||||
input.db = input.bot.db_session()
|
||||
|
||||
try:
|
||||
|
@ -132,7 +134,7 @@ class Handler(object):
|
|||
self.bot.logger.exception("Error in plugin {}:".format(self.func._filename))
|
||||
finally:
|
||||
if uses_db:
|
||||
print "Closett"
|
||||
# self.bot.logger.debug("Closed ST DB session for: {}".format(self.func._filename))
|
||||
input.db.close()
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -23,8 +23,8 @@ def db_init(db):
|
|||
|
||||
def get_tells(db, user_to):
|
||||
return db.execute("select user_from, message, time, chan from tell where"
|
||||
" user_to=lower(?) order by time",
|
||||
(user_to.lower(),)).fetchall()
|
||||
" user_to=lower(:user) order by time",
|
||||
{'user': user_to}).fetchall()
|
||||
|
||||
|
||||
@hook.singlethread
|
||||
|
@ -46,8 +46,8 @@ def tellinput(paraml, input=None, notice=None, db=None, bot=None, nick=None, con
|
|||
if len(tells) > 1:
|
||||
reply += " (+{} more, {}showtells to view)".format(len(tells) - 1, conn.conf["command_prefix"])
|
||||
|
||||
db.execute("delete from tell where user_to=lower(?) and message=?",
|
||||
(nick, message))
|
||||
db.execute("delete from tell where user_to=lower(:user) and message=:message",
|
||||
{'user': nick, 'message': message})
|
||||
db.commit()
|
||||
notice(reply)
|
||||
|
||||
|
|
Reference in a new issue