From 3a6cc1067f541cdbc123b8540cda5a130c8322e1 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 30 Oct 2026 14:52:27 +0200 Subject: [PATCH] Revert "fix(posts): split copy_text and callback_data into separate buttons per Bot API spec" This reverts commit b96bffda377e480a37774a674f16b2737491ed9d. --- VERSION | 2 +- keyboards.py | 14 ++------------ tests/test_writer_features.py | 8 +++----- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 53f6902..cfdc2af 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0+87 +0.1.0+86 diff --git a/keyboards.py b/keyboards.py index d553cc7..1e41882 100644 --- a/keyboards.py +++ b/keyboards.py @@ -103,22 +103,12 @@ def subscription_plans_keyboard() -> InlineKeyboardMarkup: def post_copy_keyboard(post_text: str, post_index: int) -> InlineKeyboardMarkup: - """Кнопка копирования поста. - - По доке Bot API (InlineKeyboardButton): «Exactly one of the fields other than - text/icon_custom_emoji_id/style must be used» — copy_text и callback_data в одной - кнопке не работают: Telegram трактует такую кнопку как callback-кнопку и копирование - не происходит. Поэтому две отдельные кнопки: левая чисто копирует текст, правая - пишет нажатие в статистику. - """ + """Кнопка копирования поста: клик копирует текст (copy_text), нажатие пишется в статистику (callback_data).""" return InlineKeyboardMarkup( inline_keyboard=[[ InlineKeyboardButton( text="📋 Скопировать", - copy_text=CopyTextButton(text=post_text[:256]), - ), - InlineKeyboardButton( - text="📊", + copy_text=CopyTextButton(text=post_text), callback_data=f"copy_post:{post_index}", ), ]], diff --git a/tests/test_writer_features.py b/tests/test_writer_features.py index 99810cb..60e7e34 100644 --- a/tests/test_writer_features.py +++ b/tests/test_writer_features.py @@ -1232,10 +1232,9 @@ class PostCopyButtonTests(unittest.IsolatedAsyncioTestCase): ): await bot._send_three_posts(cast(Any, message), ["Пост А", "Пост Б"], user_id=None) first = message.answer.await_args_list[0] - copy_button, stats_button = first.kwargs["reply_markup"].inline_keyboard[0] - self.assertEqual(copy_button.copy_text.text, "Пост А") - self.assertIsNone(copy_button.callback_data) # по доке: copy_text и callback_data в одной кнопке несовместимы - self.assertEqual(stats_button.callback_data, "copy_post:0") + button = first.kwargs["reply_markup"].inline_keyboard[0][0] + self.assertEqual(button.copy_text.text, "Пост А") + self.assertEqual(button.callback_data, "copy_post:0") async def test_copy_callback_records_event_and_keeps_button(self): callback = SimpleNamespace( @@ -1243,7 +1242,6 @@ class PostCopyButtonTests(unittest.IsolatedAsyncioTestCase): message=MagicMock(spec=bot.Message), answer=AsyncMock(), ) - callback.message.edit_reply_markup = AsyncMock() with patch.object(bot.asyncio, "to_thread", new=AsyncMock()) as to_thread: await bot.post_copy_pressed(cast(Any, callback)) to_thread.assert_awaited_once()