Actually count fish, add missing ')'

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-08 15:23:15 +01:00
parent 7cbdeaaa82
commit 43850de706
2 changed files with 6 additions and 1 deletions

3
bot.py
View file

@ -21,6 +21,7 @@ def unauth(bot, update):
update.message.reply_text(strings.unauth % setuptools.url()) update.message.reply_text(strings.unauth % setuptools.url())
def fish(bot, update): def fish(bot, update):
dbtools.dbHelper().addFish(update.message.chat_id)
update.message.reply_text("Yummy! Thanks! :3") update.message.reply_text("Yummy! Thanks! :3")
def explicitTweet(bot, update): def explicitTweet(bot, update):
@ -31,7 +32,7 @@ def tweet(bot, update):
def toggleTweet(bot, update): def toggleTweet(bot, update):
try: try:
update.message.reply_text(strings.toggleTweet % ("on" if dbtools.dbHelper().toggleTweet(update.message.chat_id) else "off") update.message.reply_text(strings.toggleTweet % ("on" if dbtools.dbHelper().toggleTweet(update.message.chat_id) else "off"))
except: except:
update.message.reply_text(strings.noauth) update.message.reply_text(strings.noauth)

View file

@ -97,6 +97,10 @@ class dbObject:
except: except:
raise ValueError("No such user: %i" % int(cid)) raise ValueError("No such user: %i" % int(cid))
def addFish(self, cid):
self.executeQuery("UPDATE tokens SET fish = fish + 1 WHERE cid = %i;" % int(cid))
self.commit()
def dbHelper(): def dbHelper():
if setuptools.dbtype() == SQLITE: if setuptools.dbtype() == SQLITE:
return dbObject(dbtype=SQLITE, path=setuptools.dbpath()) return dbObject(dbtype=SQLITE, path=setuptools.dbpath())