Bases: Dispatchable
, AriadneBaseModel
Ariadne 的事件基类
Source code in graia/ariadne/event/__init__.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 | class MiraiEvent(Dispatchable, AriadneBaseModel):
"""Ariadne 的事件基类"""
type: str
"""事件类型"""
@validator("type", allow_reuse=True)
def validate_event_type(cls, v):
"""验证事件类型, 通过比对 type 字段实现"""
if not isinstance(cls, type):
raise TypeError("cls must be a class!")
if cls.type != v:
raise InvalidEventTypeDefinition(f"{cls.__name__}'s type must be '{cls.type}', not '{v}'")
return v
Dispatcher = BaseDispatcher
|
validate_event_type
验证事件类型, 通过比对 type 字段实现
Source code in graia/ariadne/event/__init__.py
| @validator("type", allow_reuse=True)
def validate_event_type(cls, v):
"""验证事件类型, 通过比对 type 字段实现"""
if not isinstance(cls, type):
raise TypeError("cls must be a class!")
if cls.type != v:
raise InvalidEventTypeDefinition(f"{cls.__name__}'s type must be '{cls.type}', not '{v}'")
return v
|