Files
NeoBot/models/events/request.py
K2Cr2O1 00031fc7a1 refactor(models/events): 为所有事件类添加kw_only参数
统一为所有dataclass装饰的事件类添加kw_only=True参数,确保实例化时必须使用关键字参数
2026-03-21 13:59:03 +08:00

62 lines
1.2 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
from .base import OneBotEvent, EventType
@dataclass(kw_only=True)
class RequestEvent(OneBotEvent):
"""
请求事件基类
"""
request_type: str
"""请求类型"""
@property
def post_type(self) -> str:
return EventType.REQUEST
@dataclass(slots=True, kw_only=True)
class FriendRequestEvent(RequestEvent):
"""
加好友请求事件
"""
user_id: int = 0
"""发送请求的 QQ 号"""
comment: str = ""
"""验证信息"""
flag: str = ""
"""请求 flag在调用处理请求的 API 时需要传入此 flag"""
@dataclass(slots=True, kw_only=True)
class GroupRequestEvent(RequestEvent):
"""
加群请求/邀请事件
"""
sub_type: str = ""
"""
子类型
add: 加群请求
invite: 邀请登录号入群
"""
group_id: int = 0
"""群号"""
user_id: int = 0
"""发送请求的 QQ 号"""
comment: str = ""
"""验证信息"""
flag: str = ""
"""请求 flag在调用处理请求的 API 时需要传入此 flag"""