aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-22 11:08:15 -0800
committerclarkzjw <[email protected]>2023-02-22 11:08:15 -0800
commiteab21831cf13c9afdafc59adde32c85b9716e76b (patch)
treefaaf96f2ccab196a4eb307a40886ed1ad32b750c /command.py
parent0590292da6eec52e6f569749037c8f8f7bdd948e (diff)
downloadswarm2fediverse-eab21831cf13c9afdafc59adde32c85b9716e76b.tar.gz
fix /cancel flow
Diffstat (limited to 'command.py')
-rw-r--r--command.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/command.py b/command.py
index 09340fc..579fa48 100644
--- a/command.py
+++ b/command.py
@@ -1,5 +1,6 @@
1from telegram import Update 1from telegram import Update
2from telegram.constants import ParseMode 2from telegram.constants import ParseMode
3from telegram.error import BadRequest
3from telegram.ext import ContextTypes, ConversationHandler 4from telegram.ext import ContextTypes, ConversationHandler
4 5
5from config import * 6from config import *
@@ -24,5 +25,17 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
24 25
25 26
26async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: 27async 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
Powered by cgit v1.2.3 (git 2.41.0)