fix(tg): remove close_forum_topic from /archive — unsupported in Threaded Mode
This commit is contained in:
parent
d5ab527f5d
commit
fcf5be7efa
2 changed files with 8 additions and 6 deletions
|
|
@ -49,12 +49,11 @@ async def cmd_archive(message: Message) -> None:
|
||||||
if chat is None or chat["archived_at"] is not None:
|
if chat is None or chat["archived_at"] is not None:
|
||||||
await message.answer("Этот чат не найден или уже архивирован.")
|
await message.answer("Этот чат не найден или уже архивирован.")
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
await message.bot.close_forum_topic(chat_id=message.chat.id, message_thread_id=thread_id)
|
|
||||||
except TelegramBadRequest as e:
|
|
||||||
logger.warning("cmd_archive_bot_error", error=str(e))
|
|
||||||
db.archive_chat(user_id=user_id, thread_id=thread_id)
|
db.archive_chat(user_id=user_id, thread_id=thread_id)
|
||||||
await message.answer("Чат архивирован.")
|
await message.answer(
|
||||||
|
"Чат архивирован. Бот больше не будет отвечать в этом топике.\n"
|
||||||
|
"Топик останется в списке — это ограничение Telegram."
|
||||||
|
)
|
||||||
logger.info("cmd_archive", user_id=user_id, thread_id=thread_id)
|
logger.info("cmd_archive", user_id=user_id, thread_id=thread_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,11 @@ async def test_cmd_archive_closes_and_archives(fresh_db, monkeypatch):
|
||||||
fresh_db.create_chat(1, 42, "Чат #1")
|
fresh_db.create_chat(1, 42, "Чат #1")
|
||||||
msg = make_message(user_id=1, thread_id=42, chat_id=100)
|
msg = make_message(user_id=1, thread_id=42, chat_id=100)
|
||||||
await mod.cmd_archive(msg)
|
await mod.cmd_archive(msg)
|
||||||
msg.bot.close_forum_topic.assert_called_once_with(chat_id=100, message_thread_id=42)
|
# close_forum_topic is NOT called — unsupported in Threaded Mode personal chats
|
||||||
|
msg.bot.close_forum_topic.assert_not_called()
|
||||||
assert fresh_db.get_chat(1, 42)["archived_at"] is not None
|
assert fresh_db.get_chat(1, 42)["archived_at"] is not None
|
||||||
|
msg.answer.assert_called_once()
|
||||||
|
assert "архивирован" in msg.answer.call_args[0][0]
|
||||||
|
|
||||||
|
|
||||||
async def test_cmd_archive_unknown_topic_replies_error(fresh_db, monkeypatch):
|
async def test_cmd_archive_unknown_topic_replies_error(fresh_db, monkeypatch):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue