nonebot-plugin-bili-dynamic 0.1.0__py3-none-any.whl

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.
@@ -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()