From 0818e848b31b3a37550ea46152c623829215f964 Mon Sep 17 00:00:00 2001 From: banteg <4562643+banteg@users.noreply.github.com> Date: Sat, 17 Jan 2026 02:58:23 +0400 Subject: [PATCH] fix(telegram): disable link previews by default (#160) --- src/takopi/telegram/client_api.py | 2 ++ tests/test_telegram_client_api.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/takopi/telegram/client_api.py b/src/takopi/telegram/client_api.py index 392ef1c..394471d 100644 --- a/src/takopi/telegram/client_api.py +++ b/src/takopi/telegram/client_api.py @@ -392,6 +392,7 @@ class HttpBotClient: params["entities"] = entities if parse_mode is not None: params["parse_mode"] = parse_mode + params["link_preview_options"] = {"is_disabled": True} if reply_markup is not None: params["reply_markup"] = reply_markup result = await self._post("sendMessage", params) @@ -443,6 +444,7 @@ class HttpBotClient: params["entities"] = entities if parse_mode is not None: params["parse_mode"] = parse_mode + params["link_preview_options"] = {"is_disabled": True} if reply_markup is not None: params["reply_markup"] = reply_markup result = await self._post("editMessageText", params) diff --git a/tests/test_telegram_client_api.py b/tests/test_telegram_client_api.py index 184afc9..fb372da 100644 --- a/tests/test_telegram_client_api.py +++ b/tests/test_telegram_client_api.py @@ -160,12 +160,16 @@ async def test_client_methods_build_params_and_decode() -> None: assert send_call[1]["message_thread_id"] == 3 assert send_call[1]["entities"] assert send_call[1]["parse_mode"] == "Markdown" + assert send_call[1]["link_preview_options"] == {"is_disabled": True} assert send_call[1]["reply_markup"] doc_call = next(call for call in client.calls if call[0] == "sendDocument") assert doc_call[2]["caption"] == "doc" assert doc_call[3]["document"][0] == "file.txt" + edit_call = next(call for call in client.calls if call[0] == "editMessageText") + assert edit_call[1]["link_preview_options"] == {"is_disabled": True} + @pytest.mark.anyio async def test_decode_result_invalid_payload_returns_none() -> None: