bili 的 songmid 形如「BV号|cid」,与回调 data 的分隔符撞车:拆段 从 5 变 6,handle_button 判为非本 bot 按钮直接丢弃,且发生在回应 互动之前——客户端按钮一直转圈、日志无任何记录,表象即「点歌卡死」。 _song_data 给歌曲 id 一并 % 转义(_q),_song_of_data 对应 unquote; 旧按钮 id 不含 %,unquote 幂等不受影响。附 bili 往返回归测试。
This commit is contained in:
1 parent
c364506925
commit
bb60137ac7
2 files changed
+27
-5
No files matched your search
@@ -510,6 +510,25 @@ async def test_card_for_qs_song_shows_source_and_cover(env):
|
||||
assert f"" in md
|
||||
|
||||
|
||||
async def test_bili_songmid_pipe_round_trips(env):
|
||||
"""bili 的 songmid 是「BV号|cid」,自带分隔符:按钮 data 里的 id 必须
|
||||
% 转义,否则拆段变 6 段、整个回调被当成非本 bot 按钮静默丢弃(点歌
|
||||
无反应)。转义后 pick 正常弹卡片,播放/下载按钮携带完整 id。"""
|
||||
http, config = env
|
||||
api, calls = make_api()
|
||||
data = music._song_data(
|
||||
"pick",
|
||||
music.Song("bili", "BV1vg2AYdE4J|26216173455", "听", "UP主"),
|
||||
)
|
||||
assert data.count("|") == 6 # 7 段:头+action+source+id+name+singer+img
|
||||
await handle_button(api, http, config, "G1", "I1", data)
|
||||
card = posts(calls)[0]["json"]
|
||||
assert "## 听 - UP主" in card["markdown"]["content"]
|
||||
assert "来源:哔哩哔哩" in card["markdown"]["content"]
|
||||
datas = [b["action"]["data"] for b in buttons(card)[0]["buttons"]]
|
||||
assert "BV1vg2AYdE4J%7C26216173455" in datas[0] # ▶ 播放带完整 id
|
||||
|
||||
|
||||
async def test_card_cover_url_is_encoded(env):
|
||||
"""卡片封面 URL 走标准百分号编码:空格/中文转义、Markdown 语法里的
|
||||
括号也要转(否则会截断 ![]() 链接),查询串结构保留。"""
|
||||
|
||||
Reference in new issue
Block a user