本插件基于 arclet-cithun, 提供了一套通用的权限管理系统
安装
- 使用 nb-cli
nb plugin install nonebot-plugin-permission
- 使用 pip
pip install nonebot-plugin-permission
使用
设置 Matcher 级别的权限
from nonebot import on_command
from nonebot_plugin_permission import require_permission
matcher = on_command("test", rule=require_permission("command.test"))
设置 Handler 级别的权限
from nonebot import on_command
from nonebot_plugin_permission import depends_permission
matcher = on_command("test")
@matcher.handle(parameterless=depends_permission("command.test"))
async def handle():
...
依赖注入权限所有者模型
from nonebot import on_command
from nonebot_plugin_permission import UserOwner
matcher = on_command("test")
@matcher.handle()
async def handle(owner: UserOwner):
# owner 表示当前用户所代表的权限所有者
...
查看具体权限
from nonebot import on_command
from nonebot_plugin_permission import UserOwner, Permission, system
matcher = on_command("test")
@matcher.handle()
async def handle(owner: UserOwner):
state: Permission = await system.get(owner, "command.test")
通过指令设置权限
permission [@user] set <permission> <state>
通过代码设置权限
from nonebot_plugin_permission import Permission, system
@matcher.handle()
async def _():
owner = await system.get_or_create_user("xxx")
# 设置权限
await system.suset(owner, "command.test", Permission("vma"))
# 取消权限
await system.suset(owner, "command.test", Permission("v--"))
Metadata
Release files for nonebot-plugin-permission 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nonebot_plugin_permission-0.3.1.tar.gz | 17.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nonebot_plugin_permission-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.4 kB
Release files / nonebot_plugin_permission-0.3.1.tar.gz
| Download URL | nonebot_plugin_permission-0.3.1.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
187fe1da6a432530976ff057d4a9dcff407ba870202678d85fb70df33d23422b
|
|
BLAKE2b-256 checksum How to use checksums |
df3570fbdcbbf0ef6e13629c1ef15965d35e3c9a04851dea0bf938ab5890639a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.25.6 CPython/3.11.7 Windows/10
|
Release files / nonebot_plugin_permission-0.3.1-py3-none-any.whl
| Download URL | nonebot_plugin_permission-0.3.1-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58425880e38c5eb1b1289ecf3c46059741b5552b9215f8c3957cc8c3fb3d1a44
|
|
BLAKE2b-256 checksum How to use checksums |
ecd434a1a0888eed4a9a4ace0574d00e220ee29cbd47247cb2edb6cdcb2e211f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.25.6 CPython/3.11.7 Windows/10
|
Security for nonebot-plugin-permission 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.