blob: 72e1820d5b5c84543833bc8466a170151c5b26fc (
plain) (
tree)
|
|
from telegram import Update
from telegram.constants import ParseMode
from telegram.error import BadRequest
from telegram.ext import ContextTypes, ConversationHandler
from config import *
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
await update.message.reply_text(PROMPT_START, parse_mode=ParseMode.MARKDOWN)
await update.message.reply_text(PROMPT_CHOOSE_ACTION, reply_markup=MAIN_MENU)
return WAIT_LOCATION
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(PROMPT_HELP)
async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
for prompt in [PROMPT_LOCATION_KEYWORD, PROMPT_WAIT_LOCATION_CONFIRMATION, PROMPT_ADD_COMMENT, PROMPT_ADD_MEDIA]:
try:
if context.user_data.get(prompt):
await context.bot.delete_message(chat_id=update.message.chat_id,
message_id=context.user_data[prompt])
except BadRequest as e:
if "not found" in str(e.message):
pass
except Exception as e:
print(e)
await update.message.reply_text(text=PROMPT_CANCELED, reply_markup=MAIN_MENU)
context.user_data.clear()
return ConversationHandler.END
|