Files
abot/event_system/events/plugin_events.py
2025-03-18 17:40:59 +08:00

74 lines
2.3 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 event_system.event_manager import Event
from typing import Optional, Dict, Any
class PluginCallStartEvent(Event):
"""插件调用开始事件"""
def __init__(self, plugin_name: str, command: str, user_id: str,
group_id: Optional[str] = None, **kwargs):
"""
Args:
plugin_name: 插件名称
command: 触发的命令
user_id: 用户ID
group_id: 群组ID私聊为None
"""
super().__init__(
plugin_name=plugin_name,
command=command,
user_id=user_id,
group_id=group_id,
**kwargs
)
class PluginCallEndEvent(Event):
"""插件调用结束事件"""
def __init__(self, plugin_name: str, command: str, user_id: str,
group_id: Optional[str], success: bool,
process_time_ms: float, result: Any = None, **kwargs):
"""
Args:
plugin_name: 插件名称
command: 触发的命令
user_id: 用户ID
group_id: 群组ID私聊为None
success: 是否调用成功
process_time_ms: 处理时间(毫秒)
result: 处理结果
"""
super().__init__(
plugin_name=plugin_name,
command=command,
user_id=user_id,
group_id=group_id,
success=success,
process_time_ms=process_time_ms,
result=result,
**kwargs
)
class PluginErrorEvent(Event):
"""插件错误事件"""
def __init__(self, plugin_name: str, command: str, user_id: str,
group_id: Optional[str], error_message: str,
stack_trace: Optional[str] = None, **kwargs):
"""
Args:
plugin_name: 插件名称
command: 触发的命令
user_id: 用户ID
group_id: 群组ID私聊为None
error_message: 错误信息
stack_trace: 堆栈跟踪
"""
super().__init__(
plugin_name=plugin_name,
command=command,
user_id=user_id,
group_id=group_id,
error_message=error_message,
stack_trace=stack_trace,
**kwargs
)