Skip to content

Commit 07e0ccb

Browse files
committed
🎉 see you again
1 parent 9739119 commit 07e0ccb

File tree

13 files changed

+1544
-956
lines changed

13 files changed

+1544
-956
lines changed

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use flake . --impure
2+
source .venv/bin/activate

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ ci:
66
autoupdate_schedule: monthly
77
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
88
repos:
9-
- repo: https://github.com/hadialqattan/pycln
10-
rev: v2.3.0
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.5.6
1111
hooks:
12-
- id: pycln
13-
args: [--config, pyproject.toml]
12+
- id: ruff
13+
args: [--fix, --exit-non-zero-on-fix]
14+
stages: [commit]
1415

1516
- repo: https://github.com/pycqa/isort
16-
rev: 5.12.0
17+
rev: 5.13.2
1718
hooks:
1819
- id: isort
1920
stages: [commit]
2021

2122
- repo: https://github.com/psf/black
22-
rev: 23.10.1
23+
rev: 24.8.0
2324
hooks:
2425
- id: black
2526
stages: [commit]

README.md

Lines changed: 16 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,72 @@
11
<div align="center">
2-
<img width="200" src="docs/logo.png" alt="logo"></br>
2+
<img width="200" src="https://raw.githubusercontent.com/nonepkg/plugin-manager/master/docs/logo.png" alt="logo"></br>
33

4-
# Nonebot Plugin Manager
4+
# Premium Nonebot Plugin Manager
55

6-
基于 [nonebot2](https://github.com/nonebot/nonebot2)[go-cqhttp](https://github.com/Mrs4s/go-cqhttp)**非侵入式**插件管理器
6+
[NoneBot 2](https://github.com/nonebot/nonebot2)**非侵入式**插件管理器
77

88
[![License](https://img.shields.io/github/license/Jigsaw111/nonebot_plugin_manager)](LICENSE)
9-
![Python Version](https://img.shields.io/badge/python-3.7.3+-blue.svg)
10-
![NoneBot Version](https://img.shields.io/badge/nonebot-2.0.0a11+-red.svg)
9+
![Python Version](https://img.shields.io/badge/python-3.9+-blue.svg)
10+
![NoneBot Version](https://img.shields.io/badge/nonebot-2.2.1+-red.svg)
1111
![Pypi Version](https://img.shields.io/pypi/v/nonebot-plugin-manager.svg)
1212

1313
</div>
1414

1515
## 安装
1616

17-
**插件仍在~~快速~~开发中,遇到问题还请务必提 issue。**
17+
*插件重写中,之前版本的问题不再回复。*
1818

1919
### 从 PyPI 安装(推荐)
2020

21-
- 使用 nb-cli
21+
- 使用 nb-cli
2222

2323
```bash
2424
nb plugin install nonebot-plugin-manager
2525
```
2626

27-
- 使用 poetry
27+
- 使用 pdm
2828

2929
```bash
30-
poetry add nonebot-plugin-manager
31-
```
32-
33-
- 使用 pip
34-
35-
```bash
36-
pip install nonebot-plugin-manager
30+
pdm add nonebot-plugin-manager
3731
```
3832

3933
### 从 GitHub 安装(不推荐)
4034

4135
```bash
42-
git clone https://github.com/Jigsaw111/nonebot_plugin_manager.git
36+
pdm add git+https://github.com/nonepkg/plugin-manager
4337
```
4438

4539
## 使用
4640

47-
### 权限
48-
49-
权限与 UNIX 的权限类似,分为三种用户:超级用户、用户、群。
50-
51-
每种用户包含读、写、执行 3 个权限,分别对应数字 4、2、1,将 3 个权限对应的数字累加,最终得到的值即可作为每种用户所具有的权限。
52-
53-
关于会话中使用什么模式,可参照下表:
54-
55-
| 仅供参考 | 私聊读 | 群聊读 | 私聊写 | 群聊写 | 私聊执行 | 群聊执行 |
56-
| -------- | -------- | ------ | -------- | --------- | -------- | --------- |
57-
| 超级用户 | 超级用户 || 超级用户 | 超级用户 | 超级用户 ||
58-
| 用户 | 用户 || 用户 | 无权限 | 用户 | 用户 & 群 |
59-
| 群管理员 | 不存在 || 不存在 | 用户 & 群 | 不存在 | 用户 & 群 |
60-
61-
包含 Matcher 的插件默认权限为`755`,不含 Matcher 的插件默认权限为`311`
62-
63-
> 例:`npm chmod 757 nonebot_plugin_nodice`命令可将 nonebot_plugin_nodice 的权限设置为`757`
64-
> 即超级用户可写可读可执行,用户可读可执行,群可写可读可执行。
65-
66-
只有超级用户可以修改插件的权限,可以使用绝对模式(八进制数字模式)~~,符号模式~~指定文件的权限。
67-
6841
### 命令
6942

7043
**使用前请先确保命令前缀为空,否则请在以下命令前加上命令前缀 (默认为`/`)。**
7144

72-
- `npm ls`查看当前会话插件列表
73-
- `-s, --store`互斥参数,查看插件商店列表(仅超级用户可用)
74-
- `-u <user_id>, --user <user_id>`互斥参数,查看指定用户插件列表(仅超级用户可用)
75-
- `-g <group_id>, --group <group_id>`互斥参数,查看指定群插件列表(仅超级用户可用)
76-
- `-a, --all`可选参数,查看所有插件(包括不含 Matcher 的插件)
77-
78-
- `npm info <插件名>`查询插件信息 (仅超级用户可用)
79-
80-
- `npm chmod <mode> <plugin ...>`设置插件权限(仅超级用户可用)
81-
- `mode`必选参数,需要设置的权限,参考上文
82-
- `plugin ...`必选参数,需要设置的插件名
83-
- `-a, --all`可选参数,全选插件
84-
- `-r, --reverse`可选参数,反选插件
85-
86-
- `npm block <plugin ...>`禁用当前会话插件(需要权限)
45+
- `npm block/disable <plugin ...>`禁用当前会话插件(需要权限)
8746
- `plugin ...`必选参数,需要禁用的插件名
8847
- `-a, --all`可选参数,全选插件
8948
- `-r, --reverse`可选参数,反选插件
9049
- `-u <user_id ...>, --user <user_id ...>`可选参数,管理指定用户设置(仅超级用户可用)
9150
- `-g <group_id ...>, --group <group_id ...>`可选参数,管理指定群设置(仅超级用户可用)
9251

93-
- `npm unblock <plugin ...>`启用当前会话插件(需要权限)
52+
- `npm unblock/enable <plugin ...>`启用当前会话插件(需要权限)
9453
- `plugin ...`必选参数,需要禁用的插件名
9554
- `-a, --all`可选参数,全选插件
9655
- `-r, --reverse`可选参数,反选插件
9756
- `-u <user_id ...>, --user <user_id ...>`可选参数,管理指定用户设置(仅超级用户可用)
9857
- `-g <group_id ...>, --group <group_id ...>`可选参数,管理指定群设置(仅超级用户可用)
9958

100-
<!-- TODO
101-
102-
- `npm install plugin...`安装插件(仅超级用户可用)
103-
- `-i index, --index index`指定 PyPI 源
104-
105-
- `npm uninstall plugin...`卸载插件(仅超级用户可用)
106-
- `-a, --all`可选参数,全选插件
107-
108-
-->
109-
110-
## Q&A
111-
112-
- **这是什么?**
113-
基于 import hook 的插件管理器,能够在不重启 NoneBot2 的情况下分群管理插件。
114-
- **有什么用?**
115-
在 NoneBot2 仍然缺乏插件管理机制的时期暂时充当插件管理器。
116-
- **自造 Rule 不是更好?**
117-
Rule 当然更好且更有效率,但是 Rule 是一种**侵入式**的插件管理方式,需要用户自行修改其他插件的源码,这对于管理从 PyPI 安装的插件来说相对复杂。而使用本插件,你不需要修改其他插件的任何内容,更符合插件之间**松耦合**的设计原则。
118-
119-
<details>
120-
<summary>展开更多</summary>
121-
12259
## 原理
12360

12461
使用`run_preprocessor`装饰器,在 Matcher 运行之前检测其所属的 Plugin 判断是否打断。
12562

12663
事实上 Nonebot 还是加载了插件,所以只能算是**屏蔽**而非**卸载**
12764

128-
<!-- TODO
129-
130-
当然,你也可以使用`npm uninstall`命令来真正卸载插件,但我不建议你这样做,因为该命令将会重启 Nonebot 。
131-
132-
-->
133-
134-
## To Do
65+
## TODO
13566

136-
- [x] 分群插件管理
137-
- [ ] 完善权限系统
67+
- [ ] 新的权限管理
13868
- [ ] 设置插件别名
13969

140-
*咕咕咕*
141-
142-
- [ ] 安装卸载插件
143-
144-
## Bug
145-
146-
- [ ] 无法停用 Matcher 以外的机器人行为(如 APScheduler )
147-
**解决方法:** 暂无
70+
## 缺陷
14871

149-
</details>
72+
- 无法停用 Matcher 以外的机器人行为(如 APScheduler )

docs/logo.png

821 Bytes
Loading

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
description = "My flake with dream2nix packages";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
};
7+
8+
outputs =
9+
inputs @ { self
10+
, nixpkgs
11+
, ...
12+
}:
13+
let
14+
system = "x86_64-linux";
15+
pkgs = import nixpkgs {
16+
system = "x86_64-linux";
17+
};
18+
in
19+
{
20+
devShells.${system} = {
21+
default = pkgs.mkShell {
22+
packages=[pkgs.python39];
23+
NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
24+
pkgs.stdenv.cc.cc
25+
];
26+
NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker";
27+
shellHook = ''
28+
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
29+
''
30+
;
31+
};
32+
};
33+
};
34+
}

0 commit comments

Comments
 (0)