Daily build

This commit is contained in:
2026-01-02 14:22:35 +08:00
parent 87fcb78dba
commit 3f76e7d022
17 changed files with 1425 additions and 400 deletions

View File

@@ -2,10 +2,22 @@ from .message import MessageSegment
from .sender import Sender
from .events.base import OneBotEvent
from .events.message import MessageEvent, PrivateMessageEvent, GroupMessageEvent
from .events.notice import NoticeEvent
from .events.request import RequestEvent
from .events.meta import MetaEvent
from .events.notice import (
NoticeEvent, FriendAddNoticeEvent, FriendRecallNoticeEvent,
GroupRecallNoticeEvent, GroupIncreaseNoticeEvent,
GroupDecreaseNoticeEvent, GroupAdminNoticeEvent, GroupBanNoticeEvent,
GroupUploadNoticeEvent, GroupUploadFile,
NotifyNoticeEvent, PokeNotifyEvent, LuckyKingNotifyEvent, HonorNotifyEvent,
GroupCardNoticeEvent, OfflineFileNoticeEvent, OfflineFile,
ClientStatusNoticeEvent, ClientStatus, EssenceNoticeEvent
)
from .events.request import RequestEvent, FriendRequestEvent, GroupRequestEvent
from .events.meta import MetaEvent, HeartbeatEvent, LifeCycleEvent, HeartbeatStatus
from .events.factory import EventFactory
from .objects import (
GroupInfo, GroupMemberInfo, FriendInfo, StrangerInfo, LoginInfo,
VersionInfo, Status, EssenceMessage, GroupHonorInfo, CurrentTalkative, HonorInfo
)
# Alias for backward compatibility
Event = OneBotEvent
@@ -19,7 +31,42 @@ __all__ = [
"PrivateMessageEvent",
"GroupMessageEvent",
"NoticeEvent",
"FriendAddNoticeEvent",
"FriendRecallNoticeEvent",
"GroupRecallNoticeEvent",
"GroupIncreaseNoticeEvent",
"GroupDecreaseNoticeEvent",
"GroupAdminNoticeEvent",
"GroupBanNoticeEvent",
"GroupUploadNoticeEvent",
"GroupUploadFile",
"NotifyNoticeEvent",
"PokeNotifyEvent",
"LuckyKingNotifyEvent",
"HonorNotifyEvent",
"GroupCardNoticeEvent",
"OfflineFileNoticeEvent",
"OfflineFile",
"ClientStatusNoticeEvent",
"ClientStatus",
"EssenceNoticeEvent",
"RequestEvent",
"FriendRequestEvent",
"GroupRequestEvent",
"MetaEvent",
"HeartbeatEvent",
"LifeCycleEvent",
"HeartbeatStatus",
"EventFactory",
"GroupInfo",
"GroupMemberInfo",
"FriendInfo",
"StrangerInfo",
"LoginInfo",
"VersionInfo",
"Status",
"EssenceMessage",
"GroupHonorInfo",
"CurrentTalkative",
"HonorInfo",
]

View File

@@ -13,7 +13,10 @@ from .notice import (
NoticeEvent, FriendAddNoticeEvent, FriendRecallNoticeEvent,
GroupRecallNoticeEvent, GroupIncreaseNoticeEvent,
GroupDecreaseNoticeEvent, GroupAdminNoticeEvent, GroupBanNoticeEvent,
GroupUploadNoticeEvent, GroupUploadFile
GroupUploadNoticeEvent, GroupUploadFile,
NotifyNoticeEvent, PokeNotifyEvent, LuckyKingNotifyEvent, HonorNotifyEvent,
GroupCardNoticeEvent, OfflineFileNoticeEvent, OfflineFile,
ClientStatusNoticeEvent, ClientStatus, EssenceNoticeEvent
)
from .request import RequestEvent, FriendRequestEvent, GroupRequestEvent
from .meta import MetaEvent, HeartbeatEvent, LifeCycleEvent, HeartbeatStatus
@@ -204,6 +207,85 @@ class EventFactory:
user_id=data.get("user_id", 0),
file=file
)
elif notice_type == "notify":
sub_type = data.get("sub_type", "")
if sub_type == "poke":
return PokeNotifyEvent(
**common_args,
notice_type=notice_type,
sub_type=sub_type,
user_id=data.get("user_id", 0),
target_id=data.get("target_id", 0),
group_id=data.get("group_id", 0)
)
elif sub_type == "lucky_king":
return LuckyKingNotifyEvent(
**common_args,
notice_type=notice_type,
sub_type=sub_type,
user_id=data.get("user_id", 0),
group_id=data.get("group_id", 0),
target_id=data.get("target_id", 0)
)
elif sub_type == "honor":
return HonorNotifyEvent(
**common_args,
notice_type=notice_type,
sub_type=sub_type,
user_id=data.get("user_id", 0),
group_id=data.get("group_id", 0),
honor_type=data.get("honor_type", "")
)
else:
return NotifyNoticeEvent(
**common_args,
notice_type=notice_type,
sub_type=sub_type,
user_id=data.get("user_id", 0)
)
elif notice_type == "group_card":
return GroupCardNoticeEvent(
**common_args,
notice_type=notice_type,
group_id=data.get("group_id", 0),
user_id=data.get("user_id", 0),
card_new=data.get("card_new", ""),
card_old=data.get("card_old", "")
)
elif notice_type == "offline_file":
file_data = data.get("file", {})
file = OfflineFile(
name=file_data.get("name", ""),
size=file_data.get("size", 0),
url=file_data.get("url", "")
)
return OfflineFileNoticeEvent(
**common_args,
notice_type=notice_type,
user_id=data.get("user_id", 0),
file=file
)
elif notice_type == "client_status":
client_data = data.get("client", {})
client = ClientStatus(
online=client_data.get("online", False),
status=client_data.get("status", "")
)
return ClientStatusNoticeEvent(
**common_args,
notice_type=notice_type,
client=client
)
elif notice_type == "essence":
return EssenceNoticeEvent(
**common_args,
notice_type=notice_type,
sub_type=data.get("sub_type", ""),
group_id=data.get("group_id", 0),
sender_id=data.get("sender_id", 0),
operator_id=data.get("operator_id", 0),
message_id=data.get("message_id", 0)
)
else:
# 未知通知类型,返回基础通知事件
return NoticeEvent(**common_args, notice_type=notice_type)

View File

@@ -157,3 +157,143 @@ class GroupUploadNoticeEvent(GroupNoticeEvent):
"""
file: GroupUploadFile = field(default_factory=GroupUploadFile)
"""文件信息"""
@dataclass
class NotifyNoticeEvent(NoticeEvent):
"""
系统通知事件基类 (notify)
"""
sub_type: str = ""
"""
子类型
poke: 戳一戳
lucky_king: 运气王
honor: 群荣誉变更
"""
user_id: int = 0
"""发送者 QQ 号"""
@dataclass
class PokeNotifyEvent(NotifyNoticeEvent):
"""
戳一戳通知
"""
target_id: int = 0
"""被戳者 QQ 号"""
group_id: int = 0
"""群号 (如果是群内戳一戳)"""
@dataclass
class LuckyKingNotifyEvent(NotifyNoticeEvent):
"""
群红包运气王通知
"""
group_id: int = 0
"""群号"""
target_id: int = 0
"""运气王 QQ 号"""
@dataclass
class HonorNotifyEvent(NotifyNoticeEvent):
"""
群荣誉变更通知
"""
group_id: int = 0
"""群号"""
honor_type: str = ""
"""
荣誉类型
talkative: 龙王
performer: 群聊之火
emotion: 快乐源泉
"""
@dataclass
class GroupCardNoticeEvent(GroupNoticeEvent):
"""
群成员名片更新通知
"""
card_new: str = ""
"""新名片"""
card_old: str = ""
"""旧名片"""
@dataclass
class OfflineFile:
"""
离线文件信息
"""
name: str = ""
"""文件名"""
size: int = 0
"""文件大小"""
url: str = ""
"""下载链接"""
@dataclass
class OfflineFileNoticeEvent(NoticeEvent):
"""
接收离线文件通知
"""
user_id: int = 0
"""发送者 QQ 号"""
file: OfflineFile = field(default_factory=OfflineFile)
"""文件数据"""
@dataclass
class ClientStatus:
"""
客户端状态
"""
online: bool = False
"""是否在线"""
status: str = ""
"""状态描述"""
@dataclass
class ClientStatusNoticeEvent(NoticeEvent):
"""
其他客户端在线状态变更通知
"""
client: ClientStatus = field(default_factory=ClientStatus)
"""客户端信息"""
@dataclass
class EssenceNoticeEvent(GroupNoticeEvent):
"""
精华消息变动通知
"""
sub_type: str = ""
"""
子类型
add: 添加
delete: 删除
"""
sender_id: int = 0
"""消息发送者 ID"""
operator_id: int = 0
"""操作者 ID"""
message_id: int = 0
"""消息 ID"""

238
models/objects.py Normal file
View File

@@ -0,0 +1,238 @@
"""
API 响应数据模型模块
定义了 API 返回的数据结构。
"""
from dataclasses import dataclass, field
from typing import List, Optional
@dataclass
class GroupInfo:
"""
群信息
"""
group_id: int = 0
"""群号"""
group_name: str = ""
"""群名称"""
member_count: int = 0
"""成员数"""
max_member_count: int = 0
"""最大成员数"""
@dataclass
class GroupMemberInfo:
"""
群成员信息
"""
group_id: int = 0
"""群号"""
user_id: int = 0
"""QQ 号"""
nickname: str = ""
"""昵称"""
card: str = ""
"""群名片/备注"""
sex: str = "unknown"
"""性别, male 或 female 或 unknown"""
age: int = 0
"""年龄"""
area: str = ""
"""地区"""
join_time: int = 0
"""加群时间戳"""
last_sent_time: int = 0
"""最后发言时间戳"""
level: str = ""
"""成员等级"""
role: str = "member"
"""角色, owner 或 admin 或 member"""
unfriendly: bool = False
"""是否不良记录成员"""
title: str = ""
"""专属头衔"""
title_expire_time: int = 0
"""专属头衔过期时间戳"""
card_changeable: bool = False
"""是否允许修改群名片"""
@dataclass
class FriendInfo:
"""
好友信息
"""
user_id: int = 0
"""QQ 号"""
nickname: str = ""
"""昵称"""
remark: str = ""
"""备注"""
@dataclass
class StrangerInfo:
"""
陌生人信息
"""
user_id: int = 0
"""QQ 号"""
nickname: str = ""
"""昵称"""
sex: str = "unknown"
"""性别, male 或 female 或 unknown"""
age: int = 0
"""年龄"""
@dataclass
class LoginInfo:
"""
登录号信息
"""
user_id: int = 0
"""QQ 号"""
nickname: str = ""
"""昵称"""
@dataclass
class VersionInfo:
"""
版本信息
"""
app_name: str = ""
"""应用名称"""
app_version: str = ""
"""应用版本"""
protocol_version: str = ""
"""OneBot 标准版本"""
@dataclass
class Status:
"""
运行状态
"""
online: bool = False
"""是否在线"""
good: bool = True
"""运行状态是否良好"""
@dataclass
class EssenceMessage:
"""
精华消息
"""
sender_id: int = 0
"""发送者 QQ 号"""
sender_nick: str = ""
"""发送者昵称"""
sender_time: int = 0
"""发送时间"""
operator_id: int = 0
"""操作者 QQ 号"""
operator_nick: str = ""
"""操作者昵称"""
operator_time: int = 0
"""操作时间"""
message_id: int = 0
"""消息 ID"""
@dataclass
class CurrentTalkative:
"""
龙王信息
"""
user_id: int = 0
"""QQ 号"""
nickname: str = ""
"""昵称"""
avatar: str = ""
"""头像 URL"""
day_count: int = 0
"""持续天数"""
@dataclass
class HonorInfo:
"""
荣誉信息
"""
user_id: int = 0
"""QQ 号"""
nickname: str = ""
"""昵称"""
avatar: str = ""
"""头像 URL"""
description: str = ""
"""荣誉描述"""
@dataclass
class GroupHonorInfo:
"""
群荣誉信息
"""
group_id: int = 0
"""群号"""
current_talkative: Optional[CurrentTalkative] = None
"""当前龙王"""
talkative_list: List[HonorInfo] = field(default_factory=list)
"""历史龙王"""
performer_list: List[HonorInfo] = field(default_factory=list)
"""群聊之火"""
legend_list: List[HonorInfo] = field(default_factory=list)
"""群聊炽焰"""
strong_newbie_list: List[HonorInfo] = field(default_factory=list)
"""冒尖小春笋"""
emotion_list: List[HonorInfo] = field(default_factory=list)
"""快乐源泉"""