Add unauth function

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-08 13:06:17 +01:00
parent e2de6dac6a
commit 8d56dc7ae3
3 changed files with 29 additions and 3 deletions

8
bot.py
View file

@ -1,17 +1,21 @@
#!/usr/bin/env python3
import logging, setuptools, strings, telegram.ext
import dbtools, logging, setuptools, strings, telegram.ext
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
updater = telegram.ext.Updater(token=setuptools.token())
def start(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text=strings.start)
bot.sendMessage(chat_id=update.message.chat_id, text=strings.start % (setuptools.botname, setuptools.botname))
def auth(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text="Ooops. Not implemented yet.")
def unauth(bot, update):
dbtools.deleteUser(update.message.chat_id)
bot.sendMessage(chat_id=update.message.chat_id, text=strings.unauth % setuptools.url)
updater.dispatcher.add_handler(telegram.ext.CommandHandler("start", start))
updater.dispatcher.add_handler(telegram.ext.CommandHandler("auth", auth))

View file

@ -49,12 +49,24 @@ def dbpath():
###
def botname():
try:
return getSetting("Telegram", "botname")
except:
return SetupException()
def token():
try:
return getSetting("Telegram", "token")
except:
return SetupException()
def url():
try:
return getSetting("Bot", "url")
except:
return SetupExecption()
def cke():
try:
return getSetting("Twitter", "cke")

View file

@ -12,6 +12,16 @@ After authentication, you will be able to tweet from your account. Just drop me
Additionally, you will be able to use the following commands:
* [Nothing yet. Sorry.]
* /unauth - Revoke your authenticaton and stop using %s.
Have fun!'''
unauth = '''You're leaving already? :(
I hope you had a good time with me. If there is anything you would like to tell me or my developers, please drop us a note at:
* %s
Your data has been deleted. Of course, you can always just re-authenticate using /auth.
It was great having you here. So long, and thanks for all the /fish!'''