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