Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 改进 CommandGroupMatcherGroup 的结构 #1240

Merged
merged 7 commits into from
Sep 10, 2022
Prev Previous commit
Next Next commit
🔀 Merge branch 'master' into feat/on-group
A-kirami committed Sep 9, 2022

Verified

This commit was signed with the committer’s verified signature.
mcanouil Mickaël Canouil
commit 927d62cc79d297f804ed3068ae5d629058801397
9 changes: 4 additions & 5 deletions nonebot/plugin/on.py
Original file line number Diff line number Diff line change
@@ -6,10 +6,9 @@
"""
import re
import inspect
from functools import wraps
from types import ModuleType
from datetime import datetime, timedelta
from typing import Any, Set, Dict, List, Type, Tuple, Union, Callable, Optional
from typing import Any, Set, Dict, List, Type, Tuple, Union, Optional

from nonebot.adapters import Event
from nonebot.matcher import Matcher
@@ -471,6 +470,9 @@ def __init__(self, **kwargs):
self.base_kwargs: Dict[str, Any] = kwargs
"""其他传递给 `on` 的参数默认值"""

def __repr__(self) -> str:
return f"{self.__class__.__name__}(matchers={len(self.matchers)})"

def _get_final_kwargs(
self, update: Dict[str, Any], *, exclude: Optional[Set[str]] = None
) -> Dict[str, Any]:
@@ -510,9 +512,6 @@ def __init__(self, cmd: Union[str, Tuple[str, ...]], **kwargs):
self.basecmd: Tuple[str, ...] = (cmd,) if isinstance(cmd, str) else cmd
self.base_kwargs.pop("aliases", None)

def __repr__(self) -> str:
return f"CommandGroup(cmd={self.basecmd})"

def command(self, cmd: Union[str, Tuple[str, ...]], **kwargs) -> Type[Matcher]:
"""注册一个新的命令。新参数将会覆盖命令组默认值

You are viewing a condensed version of this merge commit. You can view the full changes here.