diff options
Diffstat (limited to 'command.py')
-rw-r--r-- | command.py | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1,5 +1,6 @@ | |||
1 | from telegram import Update | 1 | from telegram import Update |
2 | from telegram.constants import ParseMode | 2 | from telegram.constants import ParseMode |
3 | from telegram.error import BadRequest | ||
3 | from telegram.ext import ContextTypes, ConversationHandler | 4 | from telegram.ext import ContextTypes, ConversationHandler |
4 | 5 | ||
5 | from config import * | 6 | from config import * |
@@ -24,5 +25,17 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No | |||
24 | 25 | ||
25 | 26 | ||
26 | async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | 27 | async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: |
28 | for prompt in [PROMPT_LOCATION_KEYWORD, PROMPT_CHOOSE_POI_FROM_LIST, PROMPT_ADD_COMMENT, PROMPT_ADD_MEDIA]: | ||
29 | try: | ||
30 | if context.user_data.get(prompt): | ||
31 | await context.bot.delete_message(chat_id=update.message.chat_id, | ||
32 | message_id=context.user_data[prompt]) | ||
33 | except BadRequest as e: | ||
34 | if "not found" in str(e.message): | ||
35 | pass | ||
36 | except Exception as e: | ||
37 | print(e) | ||
38 | |||
27 | await update.message.reply_text(text=PROMPT_CANCELED, reply_markup=MAIN_MENU) | 39 | await update.message.reply_text(text=PROMPT_CANCELED, reply_markup=MAIN_MENU) |
40 | context.user_data.clear() | ||
28 | return ConversationHandler.END | 41 | return ConversationHandler.END |