From f660bc2c5e105aefa3460b0bc5710cd922d67723 Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Mon, 13 May 2024 00:37:41 +0800 Subject: [PATCH] fix edit message url --- main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 7457dc8..7ede90d 100644 --- a/main.py +++ b/main.py @@ -95,15 +95,20 @@ async def edit_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No if update.message.reply_to_message != context.user_data['message_reply']: return template = context.user_data.get('template', None) + message_url = '{1}' + url = context.user_data['message_url'] if template: - update_text = template.replace("[]", html.escape(update.message.text)) + update_text = template.replace("[]", message_url.format( + url, + html.escape(update.message.text) + )) else: update_text = html.escape(update.message.text) match = common.message_url_regex.search(update_text) if match: match = match.span() - update_text = update_text[:match[0]] + '{1}'.format( - context.user_data['message_url'], + update_text = update_text[:match[0]] + message_url.format( + url, update_text[match[0] + 1:match[1] - 1] ) + update_text[match[1]:] message_to_send = context.user_data['message_to_send']