该提交实现了完整的B站渠道插件,包含以下核心功能: 1. 支持B站直播弹幕监听与处理,包含弹幕、SC、礼物等多种直播间事件 2. 支持B站私信的轮询接收与发送 3. 内置WBI签名算法,适配B站API鉴权要求 4. 提供账号配对、黑白名单等弹幕私信权限控制 5. 集成速率限制与防风险机制,降低账号封禁风险 6. 完善的配置管理与状态监控能力
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import time
|
|
|
|
import httpx
|
|
|
|
|
|
class BilibiliProbe:
|
|
NAV_URL = "https://api.bilibili.com/x/web-interface/nav"
|
|
|
|
async def probe(self, account: dict) -> dict:
|
|
start = time.time()
|
|
try:
|
|
async with httpx.AsyncClient() as client:
|
|
resp = await client.get(
|
|
self.NAV_URL,
|
|
cookies={
|
|
"SESSDATA": account.get("sessdata", ""),
|
|
"bili_jct": account.get("bili_jct", ""),
|
|
"DedeUserID": account.get("dedeuserid", ""),
|
|
},
|
|
)
|
|
data = resp.json()
|
|
is_valid = data.get("code") == 0 and data.get("data", {}).get("isLogin")
|
|
latency = time.time() - start
|
|
|
|
return {
|
|
"ok": is_valid,
|
|
"latency_ms": int(latency * 1000),
|
|
"error": data.get("message") if not is_valid else None,
|
|
}
|
|
except Exception as e:
|
|
return {
|
|
"ok": False,
|
|
"latency_ms": int((time.time() - start) * 1000),
|
|
"error": str(e),
|
|
}
|