English | 简体中文 | 繁體中文 | 日本語 | Русский
简介
BilibiliAdapter 是基于 bilibili-api-python 的 B 站私信适配器,提供事件驱动的私信收发能力。
亮点:
- 双登录方式:Dashboard 面板扫码登录(凭据自动写入配置)/ 手动填写 Cookie 凭据
- 事件驱动私信:文本 / 图片消息实时接收,转标准 OneBot12 事件
- 图片收发:接收转 image 段(URL);发送支持 URL / 本地路径
- 多账户:
accounts下每个账户一个 B 站账号,独立会话监听 - 扫码安全:二维码会话令牌防未授权轮询;凭据面板密码形态展示
安装
epsdk install BilibiliAdapter
или:
pip install ErisPulse-BilibiliAdapter
配置说明
方式一:扫码登录(推荐)
[BilibiliAdapter.accounts.default]
login_mode = "qrcode"
bot_id = "" # auto-detect
enabled = true
配置完成后在 Dashboard → 组件配置 → Bilibili → 添加账户向导 中选择「扫码登录 B 站」,使用 B 站 APP 扫码确认,凭据自动写入配置。
方式二:Cookie 凭据
[BilibiliAdapter.accounts.default]
login_mode = "cookie"
sessdata = "YOUR_SESSDATA" # required
bili_jct = "YOUR_BILI_JCT" # required
buvid3 = "YOUR_BUVID3" # optional
dedeuserid = "YOUR_UID" # optional
bot_id = "" # auto-detect
enabled = true
Cookie 获取:浏览器登录 B 站 → F12 开发者工具 → Application → Cookies → 复制对应字段。
配置项说明(每个账户):
login_mode:登录方式,cookie(手填凭据)或qrcode(面板扫码,推荐)sessdata/bili_jct:登录态 Cookie(cookie 模式必填,面板密码形态显示)buvid3:设备指纹 Cookie(可选,降低风控概率)dedeuserid:账号 UID(可选,也是 bot_id 的默认来源)bot_id:账号 UID(留空登录后自动获取)
消息发送示例
from ErisPulse import sdk
bili = sdk.adapter.get("bilibili")
# 发送文本私信(target 为对方 UID)
await bili.Send.To("user", "123456789").Text("Hello Bilibili!")
# 发送图片(URL 或本地路径)
await bili.Send.To("user", "123456789").Image("https://example.com/pic.jpg")
# 回复消息(链式修饰)
await bili.Send.To("user", "123456789").Reply("msg_key").Text("收到!")
# 多账户
await bili.Send.Using("account2").To("user", "123456789").Text("来自第二个账号")
# OneBot12 标准段发送
message = [
{"type": "text", "data": {"text": "第一行"}},
{"type": "image", "data": {"file": "https://example.com/img.jpg"}},
]
await bili.Send.To("user", "123456789").Raw_ob12(message)
标准 Api 动作
# 自身信息
result = await bili.Api.get_self_info() # {user_id, user_name, avatar}
# 用户公开信息(昵称/头像)
result = await bili.Api.get_user_info("123456789")
# 拉取指定会话历史消息
result = await bili.Api.get_session_msgs("123456789", begin_seqno=0)
# 运行状态与版本
result = await bili.Api.get_status()
result = await bili.Api.get_version()
# 多账户
result = await bili.Api.Using("account2").get_self_info()
事件监听示例
使用 Event 模块(推荐)
@sdk.adapter.on_message()
async def on_message(event):
if event["platform"] == "bilibili":
sender = event["user_id"] # 对方 UID
text = event["alt_message"] # 纯文本内容
await event.reply("收到!") # 快捷回复
使用平台原生事件
@sdk.adapter.on("message")
async def handle_message(event):
if event["platform"] == "bilibili":
raw = event["bilibili_raw"] # B 站原始私信数据
print(f"私信来自: {raw.get('sender_uid')}")
平台事件映射关系
| B 站私信事件 | Adapter 事件 |
|---|---|
| TEXT(文本消息) | message(text 段) |
| PICTURE(图片消息) | message(image 段) |
| WITHDRAW(撤回) | 仅记录日志 |
注意事项:
- B 站无官方个人 Bot API,本适配器通过模拟登录使用 Web 私信接口,属非官方用法
- 请控制发送频率:高频/批量私信极易触发风控(账号私信功能被临时禁言),建议模块侧加节流
- 请勿用于骚扰、营销群发等违规用途,遵守 B 站社区规则
- Cookie 凭据等同账号登录态,注意保管;面板中凭据字段以密码形态显示
- 私信仅支持单聊;粉丝群聊暂不支持
- 图片接收转 image 段(URL),发送图片支持 URL / 本地路径
- 登录态失效(Cookie 过期)时适配器会记录错误日志,请重新扫码或更新 Cookie
参考链接
Metadata
Release files for ErisPulse-BilibiliAdapter 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| erispulse_bilibiliadapter-0.1.12.tar.gz | 14.6 kB | With provenance | Details for erispulse_bilibiliadapter-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| erispulse_bilibiliadapter-0.1.12-py3-none-any.whl | Python 3 | none | any | Details for erispulse_bilibiliadapter-0.1.12-py3-none-any.whl |
Total release size: 30.0 kB
Release files / erispulse_bilibiliadapter-0.1.12.tar.gz
| Download URL | erispulse_bilibiliadapter-0.1.12.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7325247aa20abb212896b6d79bbcd62763e37fa44a7e19397b3c79c4b3fc28e
|
|
BLAKE2b-256 checksum How to use checksums |
c9c9e1bf040c354964529d860823ce51d67c7468501ffd7e0d510f437d49ba63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / erispulse_bilibiliadapter-0.1.12-py3-none-any.whl
| Download URL | erispulse_bilibiliadapter-0.1.12-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3e1e3936a56a9b9faf5f4741e43fc6f4df504ea49305e38cc9acc962625987e
|
|
BLAKE2b-256 checksum How to use checksums |
fb8c0c194d6afb5f673c1c7c2162c3f1c0b7a5549a596927d4b055dd064e0727
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for ErisPulse-BilibiliAdapter 0.1.12
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for erispulse_bilibiliadapter-0.1.12.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA 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.