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
|
#!/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)
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
||||||
|
|
||||||
updater = telegram.ext.Updater(token=setuptools.token())
|
updater = telegram.ext.Updater(token=setuptools.token())
|
||||||
|
|
||||||
def start(bot, update):
|
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):
|
def auth(bot, update):
|
||||||
bot.sendMessage(chat_id=update.message.chat_id, text="Ooops. Not implemented yet.")
|
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("start", start))
|
||||||
updater.dispatcher.add_handler(telegram.ext.CommandHandler("auth", auth))
|
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():
|
def token():
|
||||||
try:
|
try:
|
||||||
return getSetting("Telegram", "token")
|
return getSetting("Telegram", "token")
|
||||||
except:
|
except:
|
||||||
return SetupException()
|
return SetupException()
|
||||||
|
|
||||||
|
def url():
|
||||||
|
try:
|
||||||
|
return getSetting("Bot", "url")
|
||||||
|
except:
|
||||||
|
return SetupExecption()
|
||||||
|
|
||||||
def cke():
|
def cke():
|
||||||
try:
|
try:
|
||||||
return getSetting("Twitter", "cke")
|
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:
|
Additionally, you will be able to use the following commands:
|
||||||
|
|
||||||
* [Nothing yet. Sorry.]
|
* /unauth - Revoke your authenticaton and stop using %s.
|
||||||
|
|
||||||
Have fun!'''
|
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