bilibili 直播间协议支持
Project description
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_keyaccess_secret开放平台提供的access_secretapp_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()解除禁言
代码实现参考
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_adapter_bilibili_live-0.2.2.tar.gz.
File metadata
- Download URL: nonebot_adapter_bilibili_live-0.2.2.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a4b74f7952f9da31672dd0c0a62606655117feef53a659c0b3e1877078e1a5d
|
|
| MD5 |
22e75bbe81daff333979fe21426b3669
|
|
| BLAKE2b-256 |
44e5d27831ff8d1b55c58bc436f1f3d7320987438092d1c3b2fbc0099314eca2
|
File details
Details for the file nonebot_adapter_bilibili_live-0.2.2-py3-none-any.whl.
File metadata
- Download URL: nonebot_adapter_bilibili_live-0.2.2-py3-none-any.whl
- Upload date:
- Size: 45.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cccb1b2292bacf83001a596ec89725c8b99966096274659645077638e1c5dae
|
|
| MD5 |
2f199c42422b003c32a280b8ed2f504a
|
|
| BLAKE2b-256 |
cd275f373b80c3b76fc4be1cac0a88193e751a98494a8fb7c0f7c25a8f579902
|