Metadata-Version: 2.4
Name: nonebot-plugin-bilidyn
Version: 0.4.1
Summary: NoneBot2 B站动态订阅推送插件
Author: Misty02600
Author-email: Misty02600 <Misty02600@gmail.com>
License-Expression: MIT
License-File: LICENSE
Requires-Dist: bilibili-api-python>=17.0.0,<18.0.0
Requires-Dist: boltons>=25.0.0
Requires-Dist: msgspec>=0.19.0
Requires-Dist: nonebot-plugin-alconna>=0.60.0,<1.0.0
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0,<1.0.0
Requires-Dist: nonebot-plugin-htmlrender>=0.3.0,<0.7.0
Requires-Dist: nonebot-plugin-localstore>=0.7.4,<1.0.0
Requires-Dist: nonebot-plugin-uniref>=0.4.1,<0.5.0
Requires-Dist: nonebot-plugin-uninfo>=0.7.0,<1.0.0
Requires-Dist: nonebot2>=2.4.2,<3.0.0
Requires-Dist: httpx
Requires-Dist: qrcode>=7.4
Requires-Dist: rapidfuzz>=3.14.3,<4.0.0
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/Misty02600/nonebot-plugin-bilidyn
Project-URL: Issues, https://github.com/Misty02600/nonebot-plugin-bilidyn/issues
Project-URL: Repository, https://github.com/Misty02600/nonebot-plugin-bilidyn.git
Description-Content-Type: text/markdown

<div align="center">
    <a href="https://v2.nonebot.dev/store">
    <img src="https://github.com/Misty02600/nonebot-plugin-template/releases/download/assets/NoneBotPlugin.png" width="310" alt="logo"></a>

## ✨ nonebot-plugin-bilidyn ✨
[![LICENSE](https://img.shields.io/github/license/Misty02600/nonebot-plugin-bilidyn.svg)](./LICENSE)
[![python](https://img.shields.io/badge/python-3.11+-blue.svg?logo=python&logoColor=white)](https://www.python.org)

[![uv](https://img.shields.io/badge/package%20manager-uv-black?logo=uv)](https://github.com/astral-sh/uv)
[![ruff](https://img.shields.io/badge/code%20style-ruff-black?logo=ruff)](https://github.com/astral-sh/ruff)

</div>

## 📖 介绍

跨平台实现的B站动态、直播订阅插件。参考了 [bilibili-dynamic-mirai-plugin](https://github.com/Colter23/bilibili-dynamic-mirai-plugin) 的绘图风格。


## 💿 安装

<details open>
<summary>使用 nb-cli 安装</summary>
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装

    nb plugin install nonebot-plugin-bilidyn --upgrade
使用 **pypi** 源安装

    nb plugin install nonebot-plugin-bilidyn --upgrade -i "https://pypi.org/simple"
使用**清华源**安装

    nb plugin install nonebot-plugin-bilidyn --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"


</details>

<details>
<summary>使用包管理器安装</summary>
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令

<details open>
<summary>uv</summary>

    uv add nonebot-plugin-bilidyn
安装仓库 main 分支

    uv add git+https://github.com/Misty02600/nonebot-plugin-bilidyn@main
</details>

<details>
<summary>pdm</summary>

    pdm add nonebot-plugin-bilidyn
安装仓库 main 分支

    pdm add git+https://github.com/Misty02600/nonebot-plugin-bilidyn@main
</details>
<details>
<summary>poetry</summary>

    poetry add nonebot-plugin-bilidyn
安装仓库 main 分支

    poetry add git+https://github.com/Misty02600/nonebot-plugin-bilidyn@main
</details>

打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入

    plugins = ["nonebot_plugin_bilidyn"]

</details>


## ⚙️ 配置

插件使用 [nonebot_plugin_localstore](https://github.com/nonebot/plugin-localstore) 储存数据和缓存。

| 配置项                             | 必填  |  默认值   | 说明                                                        |
| :--------------------------------- | :---: | :-------: | :---------------------------------------------------------- |
| `BILI_DYNAMIC_MODE`                |  否   | `per_up`  | `per_up` 逐 UP 拉取；`follow_feed` 使用登录账号的聚合关注流 |
| `BILI_DYNAMIC_INTERVAL`            |  否   |   `30`    | 动态检测间隔，单位秒                                        |
| `BILI_LIVE_INTERVAL`               |  否   |   `30`    | 直播检测间隔，单位秒                                        |
| `BILI_LOW_SPEED_START`             |  否   |    `1`    | 低频时段起始小时                                            |
| `BILI_LOW_SPEED_END`               |  否   |    `9`    | 低频时段结束小时                                            |
| `BILI_LOW_SPEED_MULTIPLIER`        |  否   |   `10`    | 低频时段检测倍率                                            |
| `BILI_THEME_COLOR`                 |  否   | `#D3EDFA` | 卡片主题色，多个颜色之间使用分号分隔。                      |
| `BILI_FONT_FILE`                   |  否   |     -     | 自定义卡片字体文件名或路径                                  |

`per_up` 逐个拉取 UP 动态，无需关注 UP，但关注数较多时会产生较多网络请求；`follow_feed` 自动关注订阅的 UP，换号、缺失时补齐关注，并从关注流筛选推送，在关注人数较多时请求消耗更少。

`BILI_FONT_FILE` 填写文件名时，从 localstore 插件配置目录下的 `fonts/` 读取；填写相对路径时，相对 Bot 运行目录读取；填写绝对路径则直接使用。

```dotenv
BILI_FONT_FILE=LXGWZhenKaiGB-Regular.ttf
# 或复用 Bot 目录中的已有字体
BILI_FONT_FILE=fonts/LXGWZhenKaiGB-Regular.ttf
```


登录失效时，插件会向最后一次成功登录所在的私聊发送一次提醒。

## 🎉 使用

### 指令表

| 指令                            |        权限        | 说明                                             |
| :------------------------------ | :----------------: | :----------------------------------------------- |
| `bili` / `bili help`            |         无         | 查看帮助文本                                     |
| `bili sub <UID>`                | 私聊 / 管理 / 超管 | 为当前会话订阅指定 UP 主                         |
| `bili unsub <UID / 名称>`       | 私聊 / 管理 / 超管 | 取消当前会话对指定 UP 主的订阅                   |
| `bili list`                     |         无         | 查看当前会话订阅列表                             |
| `bili login`                    |     私聊, 超管     | 发起二维码登录                                   |
| `bili new <UID / 名称> [count]` |         无         | 主动查看某位 UP 主最近动态，默认 1 条，最多 5 条 |


### 🎨 效果图

![动态卡片效果图](assets/dynamic-card.png)


![直播卡片效果图](assets/live-card.png)


![红色主题动态卡片效果图](assets/dynamic-card-vtb.png)


![红色主题直播卡片效果图](assets/live-card-vtb.png)
