feat: 添加状态监控插件和Redis原子操作支持
- 新增 `/status` 指令,展示机器人运行状态和系统指标 - 实现Redis Lua脚本支持原子化计数器操作 - 添加消息收发统计功能 - 完善文档,包括插件开发和性能优化指南 - 重构WebSocket连接池,增加健康检查机制 - 移除旧版编译脚本,优化项目结构
This commit is contained in:
@@ -282,3 +282,183 @@ class GroupAPI(BaseAPI):
|
||||
"""
|
||||
return await self.call_api("set_group_add_request", {"flag": flag, "sub_type": sub_type, "approve": approve, "reason": reason})
|
||||
|
||||
async def get_group_info_ex(self, group_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
获取群扩展信息 (NapCat 特有 API)。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("get_group_info_ex", {"group_id": group_id})
|
||||
|
||||
async def delete_essence_msg(self, message_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
删除精华消息。
|
||||
|
||||
Args:
|
||||
message_id (int): 目标消息的 ID。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("delete_essence_msg", {"message_id": message_id})
|
||||
|
||||
async def group_poke(self, group_id: int, user_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
在群内发送 "戳一戳"。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
user_id (int): 目标成员的 QQ 号。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("group_poke", {"group_id": group_id, "user_id": user_id})
|
||||
|
||||
async def mark_group_msg_as_read(self, group_id: int, time: int = 0) -> Dict[str, Any]:
|
||||
"""
|
||||
标记群消息为已读。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
time (int, optional): 标记此时间戳之前的消息为已读。Defaults to 0 (全部标记)。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
params = {"group_id": group_id}
|
||||
if time > 0:
|
||||
params["time"] = time
|
||||
return await self.call_api("mark_group_msg_as_read", params)
|
||||
|
||||
async def forward_group_single_msg(self, group_id: int, message_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
转发单条群消息。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
message_id (str): 要转发的消息 ID。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("forward_group_single_msg", {"group_id": group_id, "message_id": message_id})
|
||||
|
||||
async def set_group_portrait(self, group_id: int, file: str, cache: int = 1) -> Dict[str, Any]:
|
||||
"""
|
||||
设置群头像。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
file (str): 图片文件的路径或 URL 或 Base64。
|
||||
cache (int, optional): 是否使用缓存 (1: 是, 0: 否)。Defaults to 1.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("set_group_portrait", {"group_id": group_id, "file": file, "cache": cache})
|
||||
|
||||
async def _send_group_notice(self, group_id: int, content: str, **kwargs) -> Dict[str, Any]:
|
||||
"""
|
||||
发送群公告。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
content (str): 公告内容。
|
||||
**kwargs: 其他可选参数 (如 image)。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
params = {"group_id": group_id, "content": content}
|
||||
params.update(kwargs)
|
||||
return await self.call_api("_send_group_notice", params)
|
||||
|
||||
async def _get_group_notice(self, group_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
获取群公告。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("_get_group_notice", {"group_id": group_id})
|
||||
|
||||
async def _del_group_notice(self, group_id: int, notice_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
删除群公告。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
notice_id (str): 公告 ID。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("_del_group_notice", {"group_id": group_id, "notice_id": notice_id})
|
||||
|
||||
async def get_group_at_all_remain(self, group_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
获取 @全体成员 的剩余次数。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("get_group_at_all_remain", {"group_id": group_id})
|
||||
|
||||
async def get_group_system_msg(self) -> Dict[str, Any]:
|
||||
"""
|
||||
获取群系统消息。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("get_group_system_msg")
|
||||
|
||||
async def get_group_shut_list(self, group_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
获取群禁言列表。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("get_group_shut_list", {"group_id": group_id})
|
||||
|
||||
async def set_group_remark(self, group_id: int, remark: str) -> Dict[str, Any]:
|
||||
"""
|
||||
设置群备注。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
remark (str): 要设置的备注。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("set_group_remark", {"group_id": group_id, "remark": remark})
|
||||
|
||||
async def set_group_sign(self, group_id: int) -> Dict[str, Any]:
|
||||
"""
|
||||
设置群签到。
|
||||
|
||||
Args:
|
||||
group_id (int): 目标群组的群号。
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: OneBot API 的响应数据。
|
||||
"""
|
||||
return await self.call_api("set_group_sign", {"group_id": group_id})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user