Add unauth function
This commit is contained in:
parent
e2de6dac6a
commit
8d56dc7ae3
3 changed files with 29 additions and 3 deletions
8
bot.py
8
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))
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
12
strings.py
12
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!'''
|
||||
|
|
Loading…
Reference in a new issue