feat:新增napcat断线后重连重新拉取历史消息的机制
This commit is contained in:
@@ -180,6 +180,46 @@ class NapCatQueryService:
|
||||
response_data = await self._safe_call_action_data("get_msg", {"message_id": message_id})
|
||||
return response_data if isinstance(response_data, dict) else None
|
||||
|
||||
async def get_friend_message_history(
|
||||
self,
|
||||
user_id: str,
|
||||
*,
|
||||
message_seq: int | None = None,
|
||||
count: int = 20,
|
||||
reverse_order: bool = False,
|
||||
) -> Optional[NapCatPayloadList]:
|
||||
"""获取私聊历史消息列表。"""
|
||||
|
||||
params: NapCatActionResponse = {
|
||||
"user_id": user_id,
|
||||
"count": max(1, int(count)),
|
||||
"reverse_order": bool(reverse_order),
|
||||
}
|
||||
if message_seq is not None:
|
||||
params["message_seq"] = int(message_seq)
|
||||
response_data = await self._safe_call_action_data("get_friend_msg_history", params)
|
||||
return self._normalize_payload_list(response_data, action_name="get_friend_msg_history")
|
||||
|
||||
async def get_group_message_history(
|
||||
self,
|
||||
group_id: str,
|
||||
*,
|
||||
message_seq: int | None = None,
|
||||
count: int = 20,
|
||||
reverse_order: bool = False,
|
||||
) -> Optional[NapCatPayloadList]:
|
||||
"""获取群聊历史消息列表。"""
|
||||
|
||||
params: NapCatActionResponse = {
|
||||
"group_id": group_id,
|
||||
"count": max(1, int(count)),
|
||||
"reverse_order": bool(reverse_order),
|
||||
}
|
||||
if message_seq is not None:
|
||||
params["message_seq"] = int(message_seq)
|
||||
response_data = await self._safe_call_action_data("get_group_msg_history", params)
|
||||
return self._normalize_payload_list(response_data, action_name="get_group_msg_history")
|
||||
|
||||
async def get_forward_message(
|
||||
self,
|
||||
message_id: Optional[str] = None,
|
||||
|
||||
Reference in New Issue
Block a user