mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
fix template replace
This commit is contained in:
@@ -91,16 +91,16 @@ async def edit_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||||||
return
|
return
|
||||||
template = context.user_data.get('template', None)
|
template = context.user_data.get('template', None)
|
||||||
if template:
|
if template:
|
||||||
update_text = template
|
update_text = template.replace("[]", html.escape(update.message.text))
|
||||||
else:
|
else:
|
||||||
update_text = html.escape(update.message.text)
|
update_text = html.escape(update.message.text)
|
||||||
match = common.message_url_regex.search(update_text)
|
match = common.message_url_regex.search(update_text)
|
||||||
if match:
|
if match:
|
||||||
match = match.span()
|
match = match.span()
|
||||||
update_text = update_text[:match[0]] + '<a href="{0}">{1}</a>'.format(
|
update_text = update_text[:match[0]] + '<a href="{0}">{1}</a>'.format(
|
||||||
context.user_data['message_url'],
|
context.user_data['message_url'],
|
||||||
update_text[match[0] + 1:match[1] - 1] if not template else update.message.text
|
update_text[match[0] + 1:match[1] - 1]
|
||||||
) + update_text[match[1]:]
|
) + update_text[match[1]:]
|
||||||
message_to_send = context.user_data['message_to_send']
|
message_to_send = context.user_data['message_to_send']
|
||||||
await message_to_send[0].edit_caption(update_text)
|
await message_to_send[0].edit_caption(update_text)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user