mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-24 09:05:04 +08:00
Update natural_language.py
This commit is contained in:
parent
60101e7634
commit
c2de849ea7
@ -27,7 +27,7 @@ class NLProcessor:
|
||||
self.allow_empty_message = allow_empty_message
|
||||
|
||||
|
||||
def on_natural_language(keywords: Union[Optional[Iterable], Callable] = None,
|
||||
def on_natural_language(keywords: Union[Optional[Iterable], str, Callable] = None,
|
||||
*, permission: int = perm.EVERYBODY,
|
||||
only_to_me: bool = True,
|
||||
only_short_message: bool = True,
|
||||
@ -42,9 +42,6 @@ def on_natural_language(keywords: Union[Optional[Iterable], Callable] = None,
|
||||
:param allow_empty_message: handle empty messages
|
||||
"""
|
||||
|
||||
if isinstance(keywords, str):
|
||||
keywords = (keywords,)
|
||||
|
||||
def deco(func: Callable) -> Callable:
|
||||
nl_processor = NLProcessor(func=func, keywords=keywords,
|
||||
permission=permission,
|
||||
@ -58,6 +55,8 @@ def on_natural_language(keywords: Union[Optional[Iterable], Callable] = None,
|
||||
# here "keywords" is the function to be decorated
|
||||
return on_natural_language()(keywords)
|
||||
else:
|
||||
if isinstance(keywords, str):
|
||||
keywords = (keywords,)
|
||||
return deco
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user