Revert "fix(posts): keep copy button after press, count every tap"

This reverts commit 992d8645cf.
This commit is contained in:
admin committed 2026-10-30 14:52:27 +02:00
1 parent 3a6cc1067f
commit 37d8f80236
3 files changed
+12 -7

No files matched your search

+1 -1
View File
@@ -1 +1 @@
0.1.0+86
0.1.0+85
+8 -4
View File
@@ -760,12 +760,16 @@ async def clear_command(message: Message, state: FSMContext) -> None:
@router.callback_query(F.data.startswith("copy_post:"))
async def post_copy_pressed(callback: CallbackQuery) -> None:
"""Кнопка «Скопировать»: текст копирует сам Telegram (copy_text), здесь пишем только статистику.
Кнопку не убираем — она работает бесконечно, каждое нажатие считается отдельно.
"""
"""Кнопка «Скопировать»: текст копирует сам Telegram (copy_text), здесь пишем только статистику."""
if callback.from_user is not None:
await asyncio.to_thread(analytics.record_event, callback.from_user.id, "generation", "post_copy")
message = callback.message
if isinstance(message, Message):
try:
await message.edit_reply_markup(reply_markup=None)
except Exception as exc:
if "message is not modified" not in str(exc).casefold():
logger.debug("Copy button removal failed: %s", str(exc)[:120])
await callback.answer()
+3 -2
View File
@@ -1236,17 +1236,18 @@ class PostCopyButtonTests(unittest.IsolatedAsyncioTestCase):
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):
async def test_copy_callback_records_event_and_clears_button(self):
callback = SimpleNamespace(
from_user=SimpleNamespace(id=42),
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()
self.assertEqual(to_thread.await_args.args[1:], (42, "generation", "post_copy"))
callback.message.edit_reply_markup.assert_not_awaited()
callback.message.edit_reply_markup.assert_awaited_once_with(reply_markup=None)
callback.answer.assert_awaited_once()