nonebot-plugin-bili-dynamic 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nonebot_plugin_bili_dynamic-0.1.0/LICENSE +21 -0
- nonebot_plugin_bili_dynamic-0.1.0/PKG-INFO +199 -0
- nonebot_plugin_bili_dynamic-0.1.0/README.md +163 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/__init__.py +57 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/api.py +665 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/commands.py +634 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/config.py +61 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/database.py +165 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/link_parser.py +147 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/models.py +57 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/monitor.py +349 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/qrcode_login.py +253 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/renderer.py +1206 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic/translator.py +26 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic.egg-info/PKG-INFO +199 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic.egg-info/SOURCES.txt +20 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic.egg-info/dependency_links.txt +1 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic.egg-info/entry_points.txt +2 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic.egg-info/requires.txt +14 -0
- nonebot_plugin_bili_dynamic-0.1.0/nonebot_plugin_bili_dynamic.egg-info/top_level.txt +1 -0
- nonebot_plugin_bili_dynamic-0.1.0/pyproject.toml +58 -0
- nonebot_plugin_bili_dynamic-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Tony
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nonebot-plugin-bili-dynamic
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: B站动态/直播推送 NoneBot2 插件(基于 Colter23/mirai 插件移植)
|
|
5
|
+
Author: Tony
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/TonyLiangP2010405/nonebot-plugin-bili-dynamic
|
|
8
|
+
Project-URL: Repository, https://github.com/TonyLiangP2010405/nonebot-plugin-bili-dynamic
|
|
9
|
+
Keywords: nonebot,nonebot2,bilibili,bili,dynamic,live,plugin
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Communications :: Chat
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: nonebot2>=2.2.0
|
|
23
|
+
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
|
|
24
|
+
Requires-Dist: nonebot-plugin-localstore>=0.7.0
|
|
25
|
+
Requires-Dist: httpx>=0.27.0
|
|
26
|
+
Requires-Dist: pillow>=10.0.0
|
|
27
|
+
Requires-Dist: skia-python>=87.5
|
|
28
|
+
Requires-Dist: qrcode[pil]>=7.4.2
|
|
29
|
+
Requires-Dist: tortoise-orm[accel]>=0.21.0
|
|
30
|
+
Requires-Dist: aerich>=0.7.0
|
|
31
|
+
Requires-Dist: pydantic>=2.0.0
|
|
32
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
33
|
+
Provides-Extra: render
|
|
34
|
+
Requires-Dist: playwright>=1.40.0; extra == "render"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# NoneBot2 B站动态推送插件
|
|
38
|
+
|
|
39
|
+
基于 [Colter23/bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin) 移植的 **NoneBot2** 版本。
|
|
40
|
+
|
|
41
|
+
低延迟检测 B 站动态/直播并推送到 QQ 群/私聊。
|
|
42
|
+
|
|
43
|
+
## 功能
|
|
44
|
+
|
|
45
|
+
- ✅ 动态检测(图文/视频/专栏/转发等)
|
|
46
|
+
- ✅ 直播检测(开播推送)
|
|
47
|
+
- ✅ 群/私聊订阅管理
|
|
48
|
+
- ✅ 支持 @全体 配置(按动态类型)
|
|
49
|
+
- ✅ 动态过滤(类型黑名单/正则黑白名单)
|
|
50
|
+
- ✅ 管理员指令
|
|
51
|
+
- 🚧 图片渲染(后续版本加入)
|
|
52
|
+
- 🚧 推送模板系统(后续版本完善)
|
|
53
|
+
|
|
54
|
+
## 安装
|
|
55
|
+
|
|
56
|
+
### 方式一:pip 安装(推荐)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install nonebot-plugin-bili-dynamic
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 方式二:本地安装
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd nonebot-plugin-bili-dynamic
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
然后在 `bot.py` 中加载:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
nonebot.load_plugin("nonebot_plugin_bili_dynamic")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 配置
|
|
76
|
+
|
|
77
|
+
在 `.env` 或 `.env.prod` 中添加:
|
|
78
|
+
|
|
79
|
+
```env
|
|
80
|
+
# ========== B站账号(必需) ==========
|
|
81
|
+
# SESSDATA 从浏览器 Cookie 中获取
|
|
82
|
+
# 获取方法:登录B站 -> F12 -> Application -> Cookies -> www.bilibili.com -> SESSDATA
|
|
83
|
+
bili_account__sessdata="你的SESSDATA"
|
|
84
|
+
bili_account__bili_jct="你的bili_jct"
|
|
85
|
+
|
|
86
|
+
# ========== 检测间隔 ==========
|
|
87
|
+
check__interval=30 # 动态检测间隔(秒,默认30,最低10)
|
|
88
|
+
check__live_interval=20 # 直播检测间隔(秒,默认20)
|
|
89
|
+
|
|
90
|
+
# ========== 推送配置 ==========
|
|
91
|
+
push__max_images=4 # 推送最大图片数
|
|
92
|
+
push__text_only=false # 仅文本推送(不发送图片)
|
|
93
|
+
|
|
94
|
+
# ========== 过滤配置 ==========
|
|
95
|
+
filter__enable=true
|
|
96
|
+
filter__blacklist_types=["转发"]
|
|
97
|
+
|
|
98
|
+
# ========== 管理员 ==========
|
|
99
|
+
superusers=["123456789"] # 管理员QQ号列表
|
|
100
|
+
|
|
101
|
+
# ========== 调试 ==========
|
|
102
|
+
debug=false
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> ⚠️ **重要**:没有 SESSDATA 时 B 站 API 返回的数据可能不完整(仅3条评论/动态),强烈建议配置!
|
|
106
|
+
|
|
107
|
+
## 指令
|
|
108
|
+
|
|
109
|
+
| 指令 | 别名 | 说明 | 权限 |
|
|
110
|
+
|------|------|------|------|
|
|
111
|
+
| `/bili help` | `帮助` | 查看帮助 | 所有人 |
|
|
112
|
+
| `/bili add <UID>` | `订阅` | 添加订阅 | 所有人 |
|
|
113
|
+
| `/bili del <UID>` | `取消订阅` | 删除订阅 | 所有人 |
|
|
114
|
+
| `/bili list` | `订阅列表` | 查看当前订阅 | 所有人 |
|
|
115
|
+
| `/bili live <UID>` | `直播状态` | 查询直播状态 | 所有人 |
|
|
116
|
+
| `/bili new <UID> [n]` | `最新动态` | 查看最新n条动态 | 所有人 |
|
|
117
|
+
| `/bili listall` | `全部订阅` | 查看所有订阅 | 超级用户 |
|
|
118
|
+
| `/bili clear` | - | 清理失效订阅 | 超级用户 |
|
|
119
|
+
|
|
120
|
+
### 使用示例
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
# 订阅 UP 主 "小小桃纸哟"(UID: 6867955)
|
|
124
|
+
/bili add 6867955
|
|
125
|
+
|
|
126
|
+
# 查看订阅列表
|
|
127
|
+
/bili list
|
|
128
|
+
|
|
129
|
+
# 查询该 UP 直播状态
|
|
130
|
+
/bili live 6867955
|
|
131
|
+
|
|
132
|
+
# 查看最近3条动态
|
|
133
|
+
/bili new 6867955 3
|
|
134
|
+
|
|
135
|
+
# 取消订阅
|
|
136
|
+
/bili del 6867955
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 推送效果
|
|
140
|
+
|
|
141
|
+
文本推送示例:
|
|
142
|
+
```
|
|
143
|
+
📢 小小桃纸哟 发布了新视频!
|
|
144
|
+
🕐 05-10 20:30
|
|
145
|
+
|
|
146
|
+
今天给大家带来了原神萌新的第 N 期视频~
|
|
147
|
+
|
|
148
|
+
🔗 https://t.bilibili.com/xxxx
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 文件结构
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
nonebot-plugin-bili-dynamic/
|
|
155
|
+
├── nonebot_plugin_bili_dynamic/
|
|
156
|
+
│ ├── __init__.py # 插件入口
|
|
157
|
+
│ ├── config.py # 配置模型
|
|
158
|
+
│ ├── api.py # B站API封装
|
|
159
|
+
│ ├── models.py # 数据库模型
|
|
160
|
+
│ ├── database.py # 数据库操作
|
|
161
|
+
│ ├── monitor.py # 轮询检测
|
|
162
|
+
│ ├── commands.py # 指令系统
|
|
163
|
+
│ └── renderer.py # 图片渲染(TODO)
|
|
164
|
+
├── pyproject.toml
|
|
165
|
+
└── README.md
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 原项目对比
|
|
169
|
+
|
|
170
|
+
| 功能 | Mirai 版 (Colter23) | NoneBot 版 (本插件) |
|
|
171
|
+
|------|---------------------|---------------------|
|
|
172
|
+
| 动态检测 | ✅ | ✅ |
|
|
173
|
+
| 直播检测 | ✅ | ✅ |
|
|
174
|
+
| 图片渲染 (skiko) | ✅ | 🚧 开发中 |
|
|
175
|
+
| 推送模板 | ✅ 丰富 | 🚧 简化版 |
|
|
176
|
+
| 过滤系统 | ✅ 类型+正则 | ✅ 类型+正则 |
|
|
177
|
+
| 分组管理 | ✅ | 🚧 |
|
|
178
|
+
| 扫码登录 | ✅ | ❌ 手动配置Cookie |
|
|
179
|
+
| 链接解析 | ✅ | 🚧 |
|
|
180
|
+
| 翻译 | ✅ | 🚧 |
|
|
181
|
+
|
|
182
|
+
## TODO
|
|
183
|
+
|
|
184
|
+
- [ ] 图片渲染(Pillow / Playwright)
|
|
185
|
+
- [ ] 推送模板系统(多种模板切换)
|
|
186
|
+
- [ ] 分组管理
|
|
187
|
+
- [ ] 扫码登录获取 Cookie
|
|
188
|
+
- [ ] 链接解析
|
|
189
|
+
- [ ] 翻译功能
|
|
190
|
+
- [ ] 番剧订阅
|
|
191
|
+
|
|
192
|
+
## 鸣谢
|
|
193
|
+
|
|
194
|
+
- 原项目: [Colter23/bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin)
|
|
195
|
+
- NoneBot2: [nonebot/nonebot2](https://github.com/nonebot/nonebot2)
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
MIT
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# NoneBot2 B站动态推送插件
|
|
2
|
+
|
|
3
|
+
基于 [Colter23/bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin) 移植的 **NoneBot2** 版本。
|
|
4
|
+
|
|
5
|
+
低延迟检测 B 站动态/直播并推送到 QQ 群/私聊。
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
- ✅ 动态检测(图文/视频/专栏/转发等)
|
|
10
|
+
- ✅ 直播检测(开播推送)
|
|
11
|
+
- ✅ 群/私聊订阅管理
|
|
12
|
+
- ✅ 支持 @全体 配置(按动态类型)
|
|
13
|
+
- ✅ 动态过滤(类型黑名单/正则黑白名单)
|
|
14
|
+
- ✅ 管理员指令
|
|
15
|
+
- 🚧 图片渲染(后续版本加入)
|
|
16
|
+
- 🚧 推送模板系统(后续版本完善)
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
### 方式一:pip 安装(推荐)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install nonebot-plugin-bili-dynamic
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 方式二:本地安装
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cd nonebot-plugin-bili-dynamic
|
|
30
|
+
pip install -e .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
然后在 `bot.py` 中加载:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
nonebot.load_plugin("nonebot_plugin_bili_dynamic")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 配置
|
|
40
|
+
|
|
41
|
+
在 `.env` 或 `.env.prod` 中添加:
|
|
42
|
+
|
|
43
|
+
```env
|
|
44
|
+
# ========== B站账号(必需) ==========
|
|
45
|
+
# SESSDATA 从浏览器 Cookie 中获取
|
|
46
|
+
# 获取方法:登录B站 -> F12 -> Application -> Cookies -> www.bilibili.com -> SESSDATA
|
|
47
|
+
bili_account__sessdata="你的SESSDATA"
|
|
48
|
+
bili_account__bili_jct="你的bili_jct"
|
|
49
|
+
|
|
50
|
+
# ========== 检测间隔 ==========
|
|
51
|
+
check__interval=30 # 动态检测间隔(秒,默认30,最低10)
|
|
52
|
+
check__live_interval=20 # 直播检测间隔(秒,默认20)
|
|
53
|
+
|
|
54
|
+
# ========== 推送配置 ==========
|
|
55
|
+
push__max_images=4 # 推送最大图片数
|
|
56
|
+
push__text_only=false # 仅文本推送(不发送图片)
|
|
57
|
+
|
|
58
|
+
# ========== 过滤配置 ==========
|
|
59
|
+
filter__enable=true
|
|
60
|
+
filter__blacklist_types=["转发"]
|
|
61
|
+
|
|
62
|
+
# ========== 管理员 ==========
|
|
63
|
+
superusers=["123456789"] # 管理员QQ号列表
|
|
64
|
+
|
|
65
|
+
# ========== 调试 ==========
|
|
66
|
+
debug=false
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> ⚠️ **重要**:没有 SESSDATA 时 B 站 API 返回的数据可能不完整(仅3条评论/动态),强烈建议配置!
|
|
70
|
+
|
|
71
|
+
## 指令
|
|
72
|
+
|
|
73
|
+
| 指令 | 别名 | 说明 | 权限 |
|
|
74
|
+
|------|------|------|------|
|
|
75
|
+
| `/bili help` | `帮助` | 查看帮助 | 所有人 |
|
|
76
|
+
| `/bili add <UID>` | `订阅` | 添加订阅 | 所有人 |
|
|
77
|
+
| `/bili del <UID>` | `取消订阅` | 删除订阅 | 所有人 |
|
|
78
|
+
| `/bili list` | `订阅列表` | 查看当前订阅 | 所有人 |
|
|
79
|
+
| `/bili live <UID>` | `直播状态` | 查询直播状态 | 所有人 |
|
|
80
|
+
| `/bili new <UID> [n]` | `最新动态` | 查看最新n条动态 | 所有人 |
|
|
81
|
+
| `/bili listall` | `全部订阅` | 查看所有订阅 | 超级用户 |
|
|
82
|
+
| `/bili clear` | - | 清理失效订阅 | 超级用户 |
|
|
83
|
+
|
|
84
|
+
### 使用示例
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
# 订阅 UP 主 "小小桃纸哟"(UID: 6867955)
|
|
88
|
+
/bili add 6867955
|
|
89
|
+
|
|
90
|
+
# 查看订阅列表
|
|
91
|
+
/bili list
|
|
92
|
+
|
|
93
|
+
# 查询该 UP 直播状态
|
|
94
|
+
/bili live 6867955
|
|
95
|
+
|
|
96
|
+
# 查看最近3条动态
|
|
97
|
+
/bili new 6867955 3
|
|
98
|
+
|
|
99
|
+
# 取消订阅
|
|
100
|
+
/bili del 6867955
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 推送效果
|
|
104
|
+
|
|
105
|
+
文本推送示例:
|
|
106
|
+
```
|
|
107
|
+
📢 小小桃纸哟 发布了新视频!
|
|
108
|
+
🕐 05-10 20:30
|
|
109
|
+
|
|
110
|
+
今天给大家带来了原神萌新的第 N 期视频~
|
|
111
|
+
|
|
112
|
+
🔗 https://t.bilibili.com/xxxx
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 文件结构
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
nonebot-plugin-bili-dynamic/
|
|
119
|
+
├── nonebot_plugin_bili_dynamic/
|
|
120
|
+
│ ├── __init__.py # 插件入口
|
|
121
|
+
│ ├── config.py # 配置模型
|
|
122
|
+
│ ├── api.py # B站API封装
|
|
123
|
+
│ ├── models.py # 数据库模型
|
|
124
|
+
│ ├── database.py # 数据库操作
|
|
125
|
+
│ ├── monitor.py # 轮询检测
|
|
126
|
+
│ ├── commands.py # 指令系统
|
|
127
|
+
│ └── renderer.py # 图片渲染(TODO)
|
|
128
|
+
├── pyproject.toml
|
|
129
|
+
└── README.md
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 原项目对比
|
|
133
|
+
|
|
134
|
+
| 功能 | Mirai 版 (Colter23) | NoneBot 版 (本插件) |
|
|
135
|
+
|------|---------------------|---------------------|
|
|
136
|
+
| 动态检测 | ✅ | ✅ |
|
|
137
|
+
| 直播检测 | ✅ | ✅ |
|
|
138
|
+
| 图片渲染 (skiko) | ✅ | 🚧 开发中 |
|
|
139
|
+
| 推送模板 | ✅ 丰富 | 🚧 简化版 |
|
|
140
|
+
| 过滤系统 | ✅ 类型+正则 | ✅ 类型+正则 |
|
|
141
|
+
| 分组管理 | ✅ | 🚧 |
|
|
142
|
+
| 扫码登录 | ✅ | ❌ 手动配置Cookie |
|
|
143
|
+
| 链接解析 | ✅ | 🚧 |
|
|
144
|
+
| 翻译 | ✅ | 🚧 |
|
|
145
|
+
|
|
146
|
+
## TODO
|
|
147
|
+
|
|
148
|
+
- [ ] 图片渲染(Pillow / Playwright)
|
|
149
|
+
- [ ] 推送模板系统(多种模板切换)
|
|
150
|
+
- [ ] 分组管理
|
|
151
|
+
- [ ] 扫码登录获取 Cookie
|
|
152
|
+
- [ ] 链接解析
|
|
153
|
+
- [ ] 翻译功能
|
|
154
|
+
- [ ] 番剧订阅
|
|
155
|
+
|
|
156
|
+
## 鸣谢
|
|
157
|
+
|
|
158
|
+
- 原项目: [Colter23/bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin)
|
|
159
|
+
- NoneBot2: [nonebot/nonebot2](https://github.com/nonebot/nonebot2)
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NoneBot2 B站动态推送插件
|
|
3
|
+
基于 Colter23/bilibili-dynamic-mirai-plugin 移植
|
|
4
|
+
"""
|
|
5
|
+
from nonebot import require, logger, get_driver
|
|
6
|
+
from nonebot.plugin import PluginMetadata
|
|
7
|
+
|
|
8
|
+
require("nonebot_plugin_apscheduler")
|
|
9
|
+
|
|
10
|
+
from .config import plugin_config
|
|
11
|
+
from .database import init_db, close_db
|
|
12
|
+
from .monitor import monitor
|
|
13
|
+
from .api import bili_api
|
|
14
|
+
|
|
15
|
+
__plugin_meta__ = PluginMetadata(
|
|
16
|
+
name="B站动态推送",
|
|
17
|
+
description="低延迟检测B站动态/直播并推送到QQ群/私聊",
|
|
18
|
+
usage=(
|
|
19
|
+
"/bi help 查看帮助\n"
|
|
20
|
+
"/bi login B站扫码登录\n"
|
|
21
|
+
"/bi add <UID> 添加订阅\n"
|
|
22
|
+
"/bi del <UID> 取消订阅\n"
|
|
23
|
+
"/bi list 订阅列表\n"
|
|
24
|
+
"/bi live <UID> 直播状态\n"
|
|
25
|
+
"/bi new <UID> 最新动态"
|
|
26
|
+
),
|
|
27
|
+
type="application",
|
|
28
|
+
homepage="https://github.com/TonyLiangP2010405/nonebot-plugin-bili-dynamic",
|
|
29
|
+
config=None,
|
|
30
|
+
supported_adapters={"~onebot.v11"},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# 导入指令和事件(触发注册)
|
|
34
|
+
from . import commands
|
|
35
|
+
from . import link_parser
|
|
36
|
+
from . import qrcode_login
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
driver = get_driver()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@driver.on_bot_connect
|
|
43
|
+
async def on_bot_connect():
|
|
44
|
+
"""Bot连接后初始化"""
|
|
45
|
+
logger.info("[BiliDynamic] Bot已连接,初始化数据库...")
|
|
46
|
+
await init_db()
|
|
47
|
+
await monitor.start()
|
|
48
|
+
logger.info("[BiliDynamic] 插件已就绪!")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@driver.on_bot_disconnect
|
|
52
|
+
async def on_bot_disconnect():
|
|
53
|
+
"""Bot断开时清理"""
|
|
54
|
+
logger.info("[BiliDynamic] Bot断开,清理资源...")
|
|
55
|
+
await monitor.close() if hasattr(monitor, 'close') else None
|
|
56
|
+
await bili_api.close()
|
|
57
|
+
await close_db()
|