fix(#7904): QQ官方私聊主动推送不再因缺少缓存 msg_id 而跳过发送 (#7914)

* fix: QQ官方私聊主动推送不再因缺少缓存 msg_id 而跳过发送 (#7904)

- 私聊场景下 _send_by_session_common 在无缓存 msg_id 时提前 return,
导致重启后 cron 等主动推送的消息无法发送。
- 私聊主动推送不需要 msg_id,跳过此检查。

* test: 补充 QQ 官方群聊有缓存 msg_id 时正常发送的测试 (#7904)

* Delete tests/unit/test_qqofficial_adapter.py

---------

Co-authored-by: Weilong Liao <37870767+Soulter@users.noreply.github.com>
This commit is contained in:
NayukiMeko
2026-05-01 00:41:40 +08:00
committed by GitHub
parent 6f83917336
commit ffc31b305c

View File

@@ -222,8 +222,9 @@ class QQOfficialPlatformAdapter(Platform):
):
return
# 私聊主动推送不需要 msg_id见 https://github.com/AstrBotDevs/AstrBot/issues/7904
msg_id = self._session_last_message_id.get(session.session_id)
if not msg_id:
if not msg_id and session.message_type != MessageType.FRIEND_MESSAGE:
logger.warning(
"[QQOfficial] No cached msg_id for session: %s, skip send_by_session",
session.session_id,