⚗️ add export require option

This commit is contained in:
yanyongyu
2020-11-21 20:40:09 +08:00
parent b36f95862a
commit 9373bd09ed
6 changed files with 145 additions and 37 deletions

View File

@ -1,17 +1,32 @@
import re
from contextvars import ContextVar
from nonebot.typing import Rule, Matcher, Handler, Permission, RuleChecker
from nonebot.typing import Set, List, Dict, Type, Tuple, Union, Optional, ModuleType
plugins: Dict[str, "Plugin"] = ...
_tmp_matchers: Set[Type[Matcher]] = ...
_tmp_matchers: ContextVar[Set[Type[Matcher]]] = ...
_export: ContextVar["Export"] = ...
class Export(dict):
def __call__(self, func, **kwargs):
...
def __setattr__(self, name, value):
...
def __getattr__(self, name):
...
class Plugin(object):
name: str
module: ModuleType
matcher: Set[Type[Matcher]]
export: Export
def on(type: str = ...,
@ -149,6 +164,14 @@ def get_loaded_plugins() -> Set[Plugin]:
...
def export() -> Export:
...
def require(name: str) -> Export:
...
class CommandGroup:
def __init__(self,