From 7131dc496ff7a381ffd655109391e56cb4ea6cd6 Mon Sep 17 00:00:00 2001 From: poolitzer <25934244+Poolitzer@users.noreply.github.com> Date: Mon, 30 Sep 2019 12:36:54 -0700 Subject: [PATCH] closes #35. At least I hope. --- handlers/game.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handlers/game.py b/handlers/game.py index 231de5d..9cbb1d8 100644 --- a/handlers/game.py +++ b/handlers/game.py @@ -3,6 +3,7 @@ from telegram import (Update, InlineKeyboardMarkup, ParseMode, ReplyKeyboardMarkup, ReplyKeyboardRemove, ChatPermissions, InlineKeyboardButton) +from telegram.error import BadRequest from telegram.ext import CallbackContext from telegram.utils.helpers import mention_html @@ -340,7 +341,10 @@ def game_end(context, text, chat_id, chameleon_id, winner_ids, lang): context.bot.send_message(chat_id, text, parse_mode=ParseMode.HTML) if chat_data["pin"]: if isinstance(chat_data["pin"], int): - context.bot.pin_chat_message(chat_id, chat_data["pin"], True) + try: + context.bot.pin_chat_message(chat_id, chat_data["pin"], True) + except BadRequest: + context.bot.unpin_chat_message(chat_id) else: context.bot.unpin_chat_message(chat_id) chat_data.clear()