Skip to main content

NoneBot-Adapter-BiliBili-Live

B 站直播间协议支持

配置

修改 NoneBot 配置文件 .env 或者 .env.*。

Driver

请参考 driver 配置项,添加 HTTPClient 和 WebSocketClient 支持。如:

DRIVER=~httpx+~websockets
DRIVER=~aiohttp

BILIBILI_LIVE_BOTS

用户 Bot (Web API)

  • cookie 机器人账号的 Cookies,需要存在 SESSDATA(必须) 和 bili_jct(用于一些 API 调用)。
  • room_ids 监听的直播间房间号列表,长短号均可。

类型为 WebBot。

开放平台 Bot

  • access_key 开放平台提供的 access_key
  • access_secret 开放平台提供的 access_secret
  • app_id 项目 ID,在此处查看
  • identify_codes 主播身份码列表,主播身份码可以在幻星-互动玩法页面右下角 身份码 查看

类型为 OpenBot。

开放平台 Bot 无法调用任何 API。

示例

用户 Bot 配置示例:

BILIBILI_LIVE_BOTS='
[
  {
    "cookie": "SESSDATA=xxxxxxxxxxxxxxxx; bili_jct=xxxxxxxxxxxxx;",
    "room_ids": [544853]
  }
]
'

开放平台 Bot 配置示例:

BILIBILI_LIVE_BOTS='
[
  {
    "access_key": "xxxxxxxxxxxxxxxxxxxx",
    "access_secret": "xxxxxxxxxxxxxxxxxxxx",
    "app_id": 100000,
    "identify_codes": ["xxxxxxxxxxxxxxxxxxxx"]
  }
]
'

实现

标斜体的为用户 Bot 和开放平台 Bot 共有实现,粗体的为开放平台 Bot 独有实现(继承 OpenplatformOnlyEvent),其他为用户 Bot 独有实现(继承 WebOnlyEvent)。

来自开放平台的事件的 uid 均为 0,相应的存在 open_id 字段。

获取用户 ID 建议使用 event.get_user_id() 方法,而不是 event.uid 或 event.open_id。

消息类事件
  • DanmakuEvent 弹幕消息
  • SuperChatEvent 醒目留言。来自开放平台的会被认为是 to_me;来自用户 Bot 的当 Bot 为主播账号时会被认为是 to_me。
通知类事件

用户互动

  • UserEnterEvent 用户进入直播间
  • UserFollowEvent 用户关注主播
  • UserShareEvent 用户分享直播间
  • LikeEvent 点赞
  • InteractionVote 投票互动事件
  • InteractionDanmaku 弹幕互动事件
  • InteractionFollow 关注互动事件
  • InteractionGift 送礼互动事件
  • InteractionShare 分享互动事件
  • InteractionLike 点赞互动事件

礼物相关

  • SendGiftEvent 送礼
  • GuardBuyEvent 上舰通知
  • GuardBuyToastEvent 用户庆祝消息
  • SpecialGiftEvent 特殊礼物
  • GiftStarProcessEvent 礼物星球点亮

直播状态

  • OpenLiveStartEvent 开播事件
  • OpenLiveEndEvent 下播事件
  • WebLiveStartEvent 直播开始
  • OnlineRankEvent 高能榜更新
  • OnlineRankCountEvent 高能用户数量
  • OnlineRankTopEvent 到达直播间高能榜前三名
  • LikeInfoUpdateEvent 点赞数更新
  • WatchedChangeEvent 看过人数
  • StopLiveRoomListEvent 下播的直播间

直播间管理

  • RoomRealTimeMessageUpdateEvent 主播信息更新
  • RoomChangeEvent 直播间信息更改
  • ChangeRoomInfoEvent 直播间背景图片修改
  • RoomSkinMsgEvent 直播间皮肤变更
  • RoomSilentOnEvent 开启等级禁言
  • RoomSilentOffEvent 关闭等级禁言
  • RoomBlockMsgEvent 指定观众禁言
  • RoomAdminsEvent 房管列表
  • RoomAdminEntranceEvent 设立房管
  • RoomAdminRevokeEvent 撤销房管

排行榜

  • PopularRankChangedEvent 直播间在人气榜的排名改变
  • HotRankChangedEvent 直播间限时热门榜排名改变
  • HotRankSettlementEvent 限时热门榜上榜信息
  • AreaRankChangedEvent 直播间在所属分区的排名改变
元事件
  • HeartbeatEvent 心跳包,包含人气值
  • LIVE_OPEN_PLATFORM_INTERACTION_END 开放平台互动结束事件。此事件不会进入 NoneBot 事件处理流程,会由适配器自行捕获。
API 实现

API 仅限用户 Bot。

弹幕发送

  • send_danmaku() 发送弹幕消息

直播间信息

  • get_room_info() 获取直播间详细信息
  • get_user_room_status() 获取用户对应的直播间状态
  • get_master_info() 获取主播信息

用户管理

  • add_silent_user() 禁言观众
  • get_silent_user_list() 查询直播间禁言列表
  • del_silent_user() 解除禁言

代码实现参考

Metadata

Release files for nonebot-adapter-bilibili-live 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-adapter-bilibili-live 0.2.6
File Size Uploaded Provenance Actions
nonebot_adapter_bilibili_live-0.2.6.tar.gz 32.7 kB Without provenance Details for nonebot_adapter_bilibili_live-0.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-adapter-bilibili-live 0.2.6
File Interpreter ABI Platform Actions
nonebot_adapter_bilibili_live-0.2.6-py3-none-any.whl Python 3 none any Details for nonebot_adapter_bilibili_live-0.2.6-py3-none-any.whl

Total release size: 69.1 kB

Release files / nonebot_adapter_bilibili_live-0.2.6.tar.gz

Download URL nonebot_adapter_bilibili_live-0.2.6.tar.gz
Size 32.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c432f2dafa39f7a450506376140ff130b31cdb46583ccd20961d7ba9a920e958
BLAKE2b-256 checksum
How to use checksums
66dbadcdbc8371842a9976473f3a997d159ed1c72ef70e822097a379b08fe1e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nonebot_adapter_bilibili_live-0.2.6-py3-none-any.whl

Download URL nonebot_adapter_bilibili_live-0.2.6-py3-none-any.whl
Size 36.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76d9ea0a60f8685ab18bced226cacf449ff236996a138b78eef2cc000a0d1d7d
BLAKE2b-256 checksum
How to use checksums
18ad0595b2bcc42eb655d64c09b1791920f871c2d3fbfaed165a0b82c58d3872
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nonebot-adapter-bilibili-live 0.2.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page