mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-19 01:18:19 +08:00
🚨 remove some linter warning
This commit is contained in:
parent
62c0dd6e74
commit
accbf57776
@ -112,12 +112,12 @@ Permission(async_function, run_sync(sync_function))
|
||||
* **说明**: 匹配任意 `meta_event` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 meta_event type 的 Matcher。
|
||||
|
||||
|
||||
## `USER(*user, perm=<nonebot.permission.Permission object>)`
|
||||
## `USER(*user, perm=None)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在白名单内且满足 perm
|
||||
`event` 的 `session_id` 在白名单内且满足 perm
|
||||
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ Permission(async_function, run_sync(sync_function))
|
||||
* `*user: str`: 白名单
|
||||
|
||||
|
||||
* `perm: Permission`: 需要同时满足的权限
|
||||
* `perm: Optional[Permission]`: 需要同时满足的权限
|
||||
|
||||
|
||||
|
||||
|
@ -76,6 +76,7 @@ def get_driver() -> Driver:
|
||||
return _driver
|
||||
|
||||
|
||||
# FIXME: app for reverse driver
|
||||
def get_app():
|
||||
"""
|
||||
:说明:
|
||||
@ -101,6 +102,7 @@ def get_app():
|
||||
return driver.server_app
|
||||
|
||||
|
||||
# FIXME: asgi for reverse driver
|
||||
def get_asgi():
|
||||
"""
|
||||
:说明:
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""
|
||||
r"""
|
||||
权限
|
||||
====
|
||||
|
||||
@ -128,27 +128,28 @@ METAEVENT = Permission(_metaevent)
|
||||
"""
|
||||
|
||||
|
||||
def USER(*user: str, perm: Permission = Permission()):
|
||||
def USER(*user: str, perm: Optional[Permission] = None):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
在白名单内且满足 perm
|
||||
``event`` 的 ``session_id`` 在白名单内且满足 perm
|
||||
|
||||
:参数:
|
||||
|
||||
* ``*user: str``: 白名单
|
||||
* ``perm: Permission``: 需要同时满足的权限
|
||||
* ``perm: Optional[Permission]``: 需要同时满足的权限
|
||||
"""
|
||||
|
||||
async def _user(bot: "Bot", event: "Event") -> bool:
|
||||
return event.get_session_id() in user and await perm(bot, event)
|
||||
return event.get_session_id() in user and bool(perm) and await perm(
|
||||
bot, event)
|
||||
|
||||
return Permission(_user)
|
||||
|
||||
|
||||
async def _superuser(bot: "Bot", event: "Event") -> bool:
|
||||
return event.get_type() == "message" and event.get_user_id(
|
||||
) in bot.config.superusers
|
||||
return (event.get_type() == "message" and
|
||||
event.get_user_id() in bot.config.superusers)
|
||||
|
||||
|
||||
SUPERUSER = Permission(_superuser)
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""
|
||||
r"""
|
||||
规则
|
||||
====
|
||||
|
||||
@ -250,7 +250,7 @@ def keyword(*keywords: str) -> Rule:
|
||||
|
||||
|
||||
def command(*cmds: Union[str, Tuple[str, ...]]) -> Rule:
|
||||
"""
|
||||
r"""
|
||||
:说明:
|
||||
|
||||
命令形式匹配,根据配置里提供的 ``command_start``, ``command_sep`` 判断消息是否为命令。
|
||||
@ -321,7 +321,7 @@ class ArgumentParser(ArgParser):
|
||||
|
||||
def shell_command(*cmds: Union[str, Tuple[str, ...]],
|
||||
parser: Optional[ArgumentParser] = None) -> Rule:
|
||||
"""
|
||||
r"""
|
||||
:说明:
|
||||
|
||||
支持 ``shell_like`` 解析参数的命令形式匹配,根据配置里提供的 ``command_start``, ``command_sep`` 判断消息是否为命令。
|
||||
@ -394,7 +394,7 @@ def shell_command(*cmds: Union[str, Tuple[str, ...]],
|
||||
|
||||
|
||||
def regex(regex: str, flags: Union[int, re.RegexFlag] = 0) -> Rule:
|
||||
"""
|
||||
r"""
|
||||
:说明:
|
||||
|
||||
根据正则表达式进行匹配。
|
||||
|
Loading…
Reference in New Issue
Block a user