Merge branch 'main' into dev
This commit is contained in:
@@ -6,8 +6,9 @@
|
|||||||
"""
|
"""
|
||||||
import inspect
|
import inspect
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
from typing import Any, Callable, Dict, List, Optional, Tuple, TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
from ..bot import Bot
|
from ..bot import Bot
|
||||||
from ..config_loader import global_config
|
from ..config_loader import global_config
|
||||||
from ..permission import Permission
|
from ..permission import Permission
|
||||||
@@ -22,7 +23,7 @@ class BaseHandler(ABC):
|
|||||||
self.handlers: List[Dict[str, Any]] = []
|
self.handlers: List[Dict[str, Any]] = []
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def handle(self, bot: Bot, event: Any):
|
async def handle(self, bot: "Bot", event: Any):
|
||||||
"""
|
"""
|
||||||
处理事件
|
处理事件
|
||||||
"""
|
"""
|
||||||
@@ -31,7 +32,7 @@ class BaseHandler(ABC):
|
|||||||
async def _run_handler(
|
async def _run_handler(
|
||||||
self,
|
self,
|
||||||
func: Callable,
|
func: Callable,
|
||||||
bot: Bot,
|
bot: "Bot",
|
||||||
event: Any,
|
event: Any,
|
||||||
args: Optional[List[str]] = None,
|
args: Optional[List[str]] = None,
|
||||||
permission_granted: Optional[bool] = None
|
permission_granted: Optional[bool] = None
|
||||||
@@ -122,7 +123,7 @@ class MessageHandler(BaseHandler):
|
|||||||
return func
|
return func
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
async def handle(self, bot: Bot, event: Any):
|
async def handle(self, bot: "Bot", event: Any):
|
||||||
"""
|
"""
|
||||||
处理消息事件,分发给命令处理器或通用消息处理器
|
处理消息事件,分发给命令处理器或通用消息处理器
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user