From 8d56dc7ae3c7b728b77a9e8c3388f4629a36b770 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 8 Feb 2017 13:06:17 +0100 Subject: [PATCH] Add unauth function --- bot.py | 8 ++++++-- setuptools/__init__.py | 12 ++++++++++++ strings.py | 12 +++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 896b859..4f386e6 100755 --- a/bot.py +++ b/bot.py @@ -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)) diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 47a1676..e3ba12d 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -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") diff --git a/strings.py b/strings.py index 024b1b3..d16c75f 100644 --- a/strings.py +++ b/strings.py @@ -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!'''