Files
NeoBot/models/events/notice.py
2026-01-01 18:43:14 +08:00

160 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
通知事件模型模块
定义了通知相关的事件类,包括好友通知和群组通知等。
"""
from dataclasses import dataclass, field
from .base import OneBotEvent, EventType
@dataclass
class NoticeEvent(OneBotEvent):
"""
通知事件基类
"""
notice_type: str
"""通知类型"""
@property
def post_type(self) -> str:
return EventType.NOTICE
@dataclass
class FriendAddNoticeEvent(NoticeEvent):
"""
好友添加通知
"""
user_id: int = 0
"""新好友 QQ 号"""
@dataclass
class FriendRecallNoticeEvent(NoticeEvent):
"""
好友消息撤回通知
"""
user_id: int = 0
"""消息发送者 QQ 号"""
message_id: int = 0
"""被撤回的消息 ID"""
@dataclass
class GroupNoticeEvent(NoticeEvent):
"""
群组通知事件基类
"""
group_id: int = 0
"""群号"""
user_id: int = 0
"""用户 QQ 号"""
@dataclass
class GroupRecallNoticeEvent(GroupNoticeEvent):
"""
群消息撤回通知
"""
operator_id: int = 0
"""操作者 QQ 号"""
message_id: int = 0
"""被撤回的消息 ID"""
@dataclass
class GroupIncreaseNoticeEvent(GroupNoticeEvent):
"""
群成员增加通知
"""
operator_id: int = 0
"""操作者 QQ 号"""
sub_type: str = ""
"""
子类型
approve: 管理员同意入群
invite: 管理员邀请入群
"""
@dataclass
class GroupDecreaseNoticeEvent(GroupNoticeEvent):
"""
群成员减少通知
"""
operator_id: int = 0
"""操作者 QQ 号(如果是主动退群,则和 user_id 相同)"""
sub_type: str = ""
"""
子类型
leave: 主动退群
kick: 成员被踢
kick_me: 登录号被踢
disband: 群被解散
"""
@dataclass
class GroupAdminNoticeEvent(GroupNoticeEvent):
"""
群管理员变动通知
"""
sub_type: str = ""
"""
子类型
set: 设置管理员
unset: 取消管理员
"""
@dataclass
class GroupBanNoticeEvent(GroupNoticeEvent):
"""
群禁言通知
"""
operator_id: int = 0
"""操作者 QQ 号(管理员)"""
duration: int = 0
"""禁言时长(秒)0 表示解除禁言"""
sub_type: str = ""
"""
子类型
ban: 禁言
lift_ban: 解除禁言
"""
@dataclass
class GroupUploadFile:
"""
群文件信息
"""
id: str = ""
"""文件 ID"""
name: str = ""
"""文件名"""
size: int = 0
"""文件大小(Byte)"""
busid: int = 0
"""文件总线 ID"""
@dataclass
class GroupUploadNoticeEvent(GroupNoticeEvent):
"""
群文件上传通知
"""
file: GroupUploadFile = field(default_factory=GroupUploadFile)
"""文件信息"""