From 5e3fd17436a2a97e3cb0bd7a90eff3ef07857f13 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 21 May 2022 17:39:45 +0500 Subject: [PATCH 1/2] Added ability to hide a link in text --- telebot/formatting.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/telebot/formatting.py b/telebot/formatting.py index d13ba88..abec962 100644 --- a/telebot/formatting.py +++ b/telebot/formatting.py @@ -198,4 +198,14 @@ def hpre(content: str, escape: bool=True, language: str="") -> str: :param content: The string to preformatted. :param escape: True if you need to escape special characters. """ - return '
{}
'.format(language, escape_html(content) if escape else content) \ No newline at end of file + return '
{}
'.format(language, escape_html(content) if escape else content) + + +def hide_link(url: str) -> str: + """ + Hide url of an image. + + :param url: + :return: str + """ + return f'' \ No newline at end of file From 388306b7fea7344bd163ce19b2d38857d0270b26 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 21 May 2022 17:45:59 +0500 Subject: [PATCH 2/2] Updated examples --- examples/asynchronous_telebot/formatting_example.py | 2 ++ examples/formatting_example.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/asynchronous_telebot/formatting_example.py b/examples/asynchronous_telebot/formatting_example.py index 95c3d35..687daea 100644 --- a/examples/asynchronous_telebot/formatting_example.py +++ b/examples/asynchronous_telebot/formatting_example.py @@ -36,6 +36,8 @@ async def start_message(message): formatting.hunderline(message.from_user.first_name), formatting.hstrikethrough(message.from_user.first_name), formatting.hcode(message.from_user.first_name), + # hide_link is only for html + formatting.hide_link('https://telegra.ph/file/c158e3a6e2a26a160b253.jpg'), separator=" " ), parse_mode='HTML' diff --git a/examples/formatting_example.py b/examples/formatting_example.py index 1068acc..ae92252 100644 --- a/examples/formatting_example.py +++ b/examples/formatting_example.py @@ -36,6 +36,8 @@ def start_message(message): formatting.hunderline(message.from_user.first_name), formatting.hstrikethrough(message.from_user.first_name), formatting.hcode(message.from_user.first_name), + # hide_link is only for html + formatting.hide_link('https://telegra.ph/file/c158e3a6e2a26a160b253.jpg'), separator=" " ), parse_mode='HTML'