Skip to main content

Push bilibili dynamics and live notifications to QQ with NoneBot2.

Project description

nonebot-plugin-bililive

✨ 将 B 站 UP 主动态与直播推送到 QQ 的 NoneBot2 插件 ✨

license pypi python qq group

当前仓库已按 NoneBot 插件模板整理,可直接作为插件包发布到 PyPI 并在 NoneBot2 项目中安装使用。

配置发布工作流
  1. 前往 https://pypi.org/manage/account/#api-tokens 创建新的 PyPI API Token。
  2. 打开当前 GitHub 仓库的 Settings - Secrets and variables - Actions。
  3. 新建名为 PYPI_API_TOKEN 的 Repository Secret,并填入刚刚创建的 Token。

[!IMPORTANT] 当前项目使用符合 PEP 621 的 pyproject.toml,并已补充基于 tag 触发的 PyPI 发布工作流。

触发发布

创建 tag:

git tag v1.6.0post5

推送 tag:

git push origin --tags

📖 介绍

BiliLive 是一个基于 NoneBot2 的 B 站推送插件,支持将 UP 主的直播与动态消息推送到 QQ 群或私聊场景。当前项目已将发布名、插件入口、核心实现包和工作流统一整理为 nonebot-plugin-bililive,便于作为独立插件分发。

特性

  • 支持按 UP 主维度分别开启或关闭动态、直播推送。
  • 支持群内管理员权限控制,限制机器人使用范围。
  • 支持直播或动态推送时尝试 @全体成员。
  • 支持多 Bot 推送失败回退与基础异常清理。
  • 支持 Playwright 截图与验证码服务接入。

💿 安装

使用 nb-cli 安装

在 NoneBot2 项目根目录执行:

nb plugin install nonebot-plugin-bililive
使用包管理器安装
pip
pip install nonebot-plugin-bililive
pdm
pdm add nonebot-plugin-bililive
poetry
poetry add nonebot-plugin-bililive

安装后,在 NoneBot2 项目的 pyproject.toml 中加入:

plugins = ["nonebot_plugin_bililive"]

⚙️ 配置

在 NoneBot2 项目的 .env 文件中按需添加配置项:

配置项 必填 默认值 说明
BILILIVE_DIR data 数据目录
BILILIVE_TO_ME true 是否需要 @机器人 或命令前缀触发
BILILIVE_PROXY HTTP 代理地址,用于 B 站请求和 Playwright 下载
BILILIVE_INTERVAL 10 默认轮询间隔,单位秒
BILILIVE_LIVE_INTERVAL 10 直播轮询间隔,单位秒
BILILIVE_DYNAMIC_INTERVAL 0 动态轮询间隔,单位秒,0 表示使用默认逻辑
BILILIVE_DYNAMIC_AT false 动态推送时是否尝试 @全体
BILILIVE_LIVE_OFF_NOTIFY false 是否推送下播通知
BILILIVE_CAPTCHA_ADDRESS https://captcha-cd.ngworks.cn 验证码识别服务地址
BILILIVE_CAPTCHA_TOKEN bililive 验证码服务 token
BILILIVE_DYNAMIC_TIMEOUT 30 动态截图超时时间,单位秒
BILILIVE_DYNAMIC_FONT_SOURCE system 截图字体来源
BILILIVE_DYNAMIC_FONT Noto Sans CJK SC 截图字体
BILILIVE_DYNAMIC_BIG_IMAGE false 是否优先展示大图
BILILIVE_COMMAND_PREFIX 空字符串 命令额外前缀

🎉 使用

指令表

指令 权限 需要@ 范围 说明
帮助 群员 视 BILILIVE_TO_ME 而定 群聊/私聊 查看帮助信息
关注 UID 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 订阅指定 UP
取关 UID 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 取消订阅
关注列表 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 查看当前订阅
开启直播 UID 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 开启某 UP 的直播推送
关闭直播 UID 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 关闭某 UP 的直播推送
开启动态 UID 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 开启某 UP 的动态推送
关闭动态 UID 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 关闭某 UP 的动态推送
开启全体 UID 管理员 视 BILILIVE_TO_ME 而定 群聊 开启直播推送 @全体
关闭全体 UID 管理员 视 BILILIVE_TO_ME 而定 群聊 关闭直播推送 @全体
开启权限 管理员 视 BILILIVE_TO_ME 而定 群聊 限制仅管理员可使用
关闭权限 管理员 视 BILILIVE_TO_ME 而定 群聊 关闭管理员权限限制
已开播 群员/管理员 视 BILILIVE_TO_ME 而定 群聊/私聊 查看已开播关注列表

效果图

demo

开发

本仓库保留了本地开发启动方式:

python bot.py

用于发布的插件入口模块为:

nonebot_plugin_bililive

致谢

许可证

本项目使用 GNU AGPLv3 作为开源许可证。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_bililive-2.0.1.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_bililive-2.0.1-py3-none-any.whl (56.5 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_bililive-2.0.1.tar.gz.

File metadata

  • Download URL: nonebot_plugin_bililive-2.0.1.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.7 CPython/3.12.3 Linux/6.17.0-1010-azure

File hashes

Hashes for nonebot_plugin_bililive-2.0.1.tar.gz
Algorithm Hash digest
SHA256 35556fe427214c820920a9b8e7d67666a55a66547f81a625fa7b25118c72bb95
MD5 65c1525828b4a9dc6e9ff7105e353a9d
BLAKE2b-256 45780115b219005800d214d11ce68d04a04f8ed6494fa0526b325d20822eb757

See more details on using hashes here.

File details

Details for the file nonebot_plugin_bililive-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_bililive-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31fc03d9e6cc3abf6bfa72e0f55aeb6cde58345683df13b4af9f5141cf53c45d
MD5 12b7ac08cfcd4966a882b90c74ad4741
BLAKE2b-256 d79346da734defef069e537f0c3aea26eb4747d1db9df2220fa3865a7e198f93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page