Skip to main content

NoneBot2 plugin for pushing update and live notifications from Bibibili.

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-bilibili-notifier

✨ B站UP更新与开播通知插件 ✨

license pypi python

📖 介绍

插件会定时拉取B站动态和开播信息,并将匹配UP主的消息推送到指定QQ群。支持:

  • 动态/视频更新推送
  • 开播推送
  • 自动点赞(按UP mid 或昵称)
  • 推送目标支持按 UP mid 或昵称配置
  • 转发动态原文控制(全文/关闭)
  • 动态多页抓取

默认使用 SAA 发送消息(理论上支持 SAA 支持的所有平台)。也可以通过 bnotifier_use_saa = false 关闭 SAA 依赖,直接使用 OneBot v11 原生 API 发送,此时无需安装 SAA。

💿 安装

使用 nb-cli 安装

在 nonebot2 项目根目录执行:

nb plugin install nonebot-plugin-bilibili-notifier
使用包管理器安装
pip install nonebot-plugin-bilibili-notifier
# 或 pdm add nonebot-plugin-bilibili-notifier
# 或 poetry add nonebot-plugin-bilibili-notifier

然后在 pyproject.toml[tool.nonebot] 中加入:

plugins = ["nonebot_plugin_bilibili_notifier"]

⚙️ 配置

在 NoneBot 项目的 .env 中配置以下字段。

必填项

配置项 默认值 说明
bnotifier_cookies cookies JSON 文件路径

推送目标

配置项 默认值 说明
bnotifier_push_updates {} 更新推送,格式 {UP标识: [group_id, ...]},UP标识可为 mid 或昵称
bnotifier_push_lives {} 开播推送,格式 {UP标识: [group_id, ...]},UP标识可为 mid 或昵称
bnotifier_push_updates_by_group {} 按群配置更新推送,格式 {group_id: [UP标识, ...]},UP标识可为 mid 或昵称;当 group_id 为空字符串时,UP 仍会被记录,但只会发给 bnotifier_debug_user,不发群
bnotifier_push_lives_by_group {} 按群配置开播推送,格式 {group_id: [UP标识, ...]},UP标识可为 mid 或昵称;当 group_id 为空字符串时,UP 仍会被记录,但只会发给 bnotifier_debug_user,不发群
bnotifier_push_type_blacklist {} 动态类型黑名单,格式 {group_id或UP标识: [dynamic_type, ...]},UP标识可为 mid 或昵称
bnotifier_debug_user [] 额外接收所有推送的QQ私聊用户ID列表

业务行为

配置项 默认值 说明
bnotifier_like [] 自动点赞目标(UP mid 或昵称)
bnotifier_forward_message_mode "full" 转发原文模式:full/none
bnotifier_skip_lottery_forward true 是否跳过包含“中奖”的转发动态

适配器

配置项 默认值 说明
bnotifier_use_saa true 是否使用 SAA 发送消息。true 时依赖 nonebot-plugin-saa 并支持多平台;false 时直接调用 OneBot v11 API,无需 SAA

拉取与性能

配置项 默认值 说明
bnotifier_dynamic_update_interval 120 动态轮询间隔(秒)
bnotifier_live_update_interval 60 开播轮询间隔(秒)
bnotifier_dynamic_pages 1 每轮动态抓取页数
bnotifier_dynamic_features "itemOpusStyle" 动态接口 features 参数
bnotifier_timezone_offset -480 动态接口 timezone_offset 参数
bnotifier_live_fetch_size 50 每轮直播列表抓取数量
bnotifier_api_timeout 20 API 超时时间(秒)

状态与启动行为

配置项 默认值 说明
bnotifier_ignore_old_dynamic_on_start true 首次运行(无已知动态记录)时是否忽略历史动态
bnotifier_state_file "last_update.json" 状态文件名(缓存目录下),用于持久化已知动态ID集合

🛠️ 调试命令

  • 命令:/bnotifier_parse <动态ID>
  • 示例:/bnotifier_parse 1175425797536612360
  • 权限:发送者必须在 bnotifier_debug_user 列表或 NoneBot SUPERUSERS
  • 行为:按动态ID拉取并解析动态,然后将消息推送给发送者

📢 推送失败通知

当向群或调试用户推送动态失败时,插件会自动向 bnotifier_debug_user 中的用户发送失败通知,包含动态链接和失败详情。

🍪 cookies 文件格式

支持以下两种格式。

对象格式:

{
  "sessdata": "...",
  "bili_jct": "...",
  "buvid3": "...",
  "dedeuserid": "..."
}

列表格式(浏览器导出常见格式):

[
  {"name": "SESSDATA", "value": "..."},
  {"name": "bili_jct", "value": "..."},
  {"name": "buvid3", "value": "..."},
  {"name": "DedeUserID", "value": "..."}
]

🧪 配置示例

bnotifier_cookies="/path/to/cookies.json"

# 按 mid 配置(数字UID)
bnotifier_push_updates={"823532":["123456"]}
bnotifier_push_lives={"823532":["123456"]}

# 也可以用昵称配置
# bnotifier_push_updates={"某UP主":["123456"]}

bnotifier_like=["823532"]
bnotifier_debug_user=["10001"]

# 直接使用 OneBot v11 发送(不需要安装 SAA)
bnotifier_use_saa=false

其它

有问题或需求欢迎提 issue。

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_bilibili_notifier-0.4.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file nonebot_plugin_bilibili_notifier-0.4.0.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_bilibili_notifier-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6ef2db83c894e590409d2c834fafcd61ec36cf841c77808f0b549b041b3eb22d
MD5 b59295ae2105200ee76d913140b4f9d1
BLAKE2b-256 db71f49c776e6cc22a811279ae323fee5be0f77d444af3354407892c74500a42

See more details on using hashes here.

File details

Details for the file nonebot_plugin_bilibili_notifier-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_bilibili_notifier-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 961f84263cd6c8d9ba97162516959c3ff7ad88cbdd9fa9176646e2ac56cf109c
MD5 e2c49d341a26b1eb08d20abc4c0ae499
BLAKE2b-256 5153091c133a84b19a4b58cb4e8973e11a66d622ddc3b579cc9673e20cecbc54

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