Squash merge dev branch: Implement performance monitoring, auto-approve plugin, and fix various warnings
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
定义了消息相关的事件类,包括 MessageEvent, PrivateMessageEvent, GroupMessageEvent。
|
||||
"""
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Optional, Union, ClassVar
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from core.permission import Permission
|
||||
from models.message import MessageSegment
|
||||
@@ -27,17 +27,19 @@ class Anonymous:
|
||||
"""匿名用户 flag"""
|
||||
|
||||
|
||||
# 权限级别常量,用于装饰器参数
|
||||
# 定义在类外部,避免 dataclass 参数顺序问题
|
||||
MESSAGE_EVENT_ADMIN = Permission.ADMIN
|
||||
MESSAGE_EVENT_OP = Permission.OP
|
||||
MESSAGE_EVENT_USER = Permission.USER
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class MessageEvent(OneBotEvent):
|
||||
"""
|
||||
消息事件基类
|
||||
"""
|
||||
|
||||
# 权限级别常量,用于装饰器参数
|
||||
ADMIN: ClassVar[Permission] = Permission.ADMIN
|
||||
OP: ClassVar[Permission] = Permission.OP
|
||||
USER: ClassVar[Permission] = Permission.USER
|
||||
|
||||
message_type: str
|
||||
"""消息类型: private (私聊), group (群聊)"""
|
||||
|
||||
@@ -70,6 +72,21 @@ class MessageEvent(OneBotEvent):
|
||||
def post_type(self) -> str:
|
||||
return EventType.MESSAGE
|
||||
|
||||
@property
|
||||
def ADMIN(self) -> Permission:
|
||||
"""权限级别常量,用于装饰器参数"""
|
||||
return MESSAGE_EVENT_ADMIN
|
||||
|
||||
@property
|
||||
def OP(self) -> Permission:
|
||||
"""权限级别常量,用于装饰器参数"""
|
||||
return MESSAGE_EVENT_OP
|
||||
|
||||
@property
|
||||
def USER(self) -> Permission:
|
||||
"""权限级别常量,用于装饰器参数"""
|
||||
return MESSAGE_EVENT_USER
|
||||
|
||||
async def reply(self, message: Union[str, "MessageSegment", List["MessageSegment"]], auto_escape: bool = False):
|
||||
"""
|
||||
回复消息(抽象方法,由子类实现)
|
||||
@@ -119,4 +136,4 @@ class GroupMessageEvent(MessageEvent):
|
||||
"""
|
||||
await self.bot.send_group_msg(
|
||||
group_id=self.group_id, message=message, auto_escape=auto_escape
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user