Step 1 of token management in PM

This commit is contained in:
Derek Schmidt 2018-06-27 00:36:36 +00:00
parent c734bd86c9
commit 64d8e0408f
Signed by: skeh
GPG key ID: 0F5D491793B4035A

13
main.py
View file

@ -55,7 +55,7 @@ def register(message):
bot.send_message(message.chat.id, "Badabing, badaboom. Token PM'ed to you!", parse_mode='Markdown')
except ApiException as e:
if e.result.status_code == 403:
bot.send_message(message.chat.id, "Badabing, bada...bish. We tried to PM a token to you, but were blocked. Send /start in a PM to get things sorted!", parse_mode='Markdown')
bot.send_message(message.chat.id, "Badabing, bada...bish. We tried to PM a token to you, but were blocked. Send /tokens in a PM to get things sorted!", parse_mode='Markdown')
else:
raise e
help(message)
@ -78,6 +78,16 @@ def revoke(message, chat=None):
except Exception as e:
oops(message, e)
@bot.channel_post_handler(func=lambda msg: channel_commands(msg, ['token']))
@bot.message_handler(commands=['token'])
def get_tokens(message):
chats = Chat.query.filter_by(user_id=message.from_user.id)
markup = telebot.types.ReplyKeyboardMarkup(row_width=1)
for chat in chats:
button = telebot.types.KeyboardButton(chat.get_friendly_name(bot))
markup.add(button)
bot.send_message(message.chat.id, "Which chat?", reply_markup=markup)
@bot.channel_post_handler(func=lambda msg: channel_commands(msg, ['ping']))
@bot.message_handler(commands=['ping'])
def ping(message):
@ -114,7 +124,6 @@ def send(token):
else:
abort(415)
@app.route('/webhook/<key>/', methods=['POST'])
def webhook(key):
if key == app.config['bot']['token']: