Added database field for /toggletweet
This commit is contained in:
parent
6beb8f6137
commit
cb3f9654da
2 changed files with 11 additions and 1 deletions
10
bot.py
10
bot.py
|
@ -3,6 +3,10 @@
|
|||
import dbtools, logging, setuptools, strings, telegram.ext
|
||||
|
||||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def log(bot, update, error):
|
||||
logger.warn("Error %s caused by '%s'" % (error, update))
|
||||
|
||||
updater = telegram.ext.Updater(token=setuptools.token())
|
||||
|
||||
|
@ -22,11 +26,17 @@ def fish(bot, update):
|
|||
def tweet(bot, update):
|
||||
update.message.reply_text("Ooops. Not implemented yet.")
|
||||
|
||||
def unknown(bot, update):
|
||||
update.message.reply_text("Sorry, I didn't understand that command.")
|
||||
|
||||
updater.dispatcher.add_handler(telegram.ext.CommandHandler("start", start))
|
||||
updater.dispatcher.add_handler(telegram.ext.CommandHandler("auth", auth))
|
||||
updater.dispatcher.add_handler(telegram.ext.CommandHandler("unauth", unauth))
|
||||
updater.dispatcher.add_handler(telegram.ext.CommandHandler("fish", fish))
|
||||
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.text, tweet))
|
||||
updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.command, unknown))
|
||||
|
||||
updater.dispatcher.add_error_handler(log)
|
||||
|
||||
updater.start_polling()
|
||||
updater.idle()
|
||||
|
|
2
setup.py
2
setup.py
|
@ -49,7 +49,7 @@ if dbtype == dbtools.MYSQL:
|
|||
else:
|
||||
db = dbtools.dbObject(dbtype=dbtype, path=dbpath)
|
||||
if not db.isInitialized():
|
||||
db.executeQuery("CREATE TABLE tokens(`cid` INT PRIMARY KEY, `ato` TEXT, `ase` TEXT, `fish` INT DEFAULT 0);")
|
||||
db.executeQuery("CREATE TABLE tokens(`cid` INT PRIMARY KEY, `ato` TEXT, `ase` TEXT, `tweet` BOOLEAN DEFAULT 1, `fish` INT DEFAULT 0);")
|
||||
db.commit()
|
||||
|
||||
db.closeConnection()
|
||||
|
|
Loading…
Reference in a new issue