-
Notifications
You must be signed in to change notification settings - Fork 315
Open
Labels
question这啥呀这是,我不到啊这啥呀这是,我不到啊
Description
Python 版本: 3.10
模块版本: 17.3.0
运行环境: Windows / Linux / MacOS
Windows
代码如下:
session = Session(credential, debug=True)
@session.on(EventType.TEXT)
async def handle_text(event):
print(f"收到来自 {event.sender_uid} 的消息: {event.content}")
await session.reply(event, f"您说: {event.content}")
asyncio.run(session.start())
私信发了消息在日志中能看到但是无法触发回复,deepwiki分析说
从你的日志可以看到:
初始化时获取的会话信息:'ack_seqno': 2143087447486472(已读到的位置)
初始化时的 max_seqno: 2152132631875595(最新消息位置)
你发送"测试消息"后的新 max_seqno: 2152135785979907
但 fetch_session_msgs 使用 begin_seqno: 2152132631875595 请求,返回 messages: None
问题的本质:这些消息的 msg_seqno 都小于或等于 ack_seqno(已读位置),所以 Bilibili API 认为这些是"已读消息",不会返回。 session.py:542-545
解决方案:
你需要在另一个账号发送消息后,在你的 bot 账号上不要点开这个会话(不要标记为已读)。这样 ack_seqno 就不会更新,新消息才能被获取到。
但测试全程未在其他设备登录bot账号
日志如下:
[BILIBILI_API][2025-11-24 16:34:42,692][INFO] Api 发起请求: {'url': 'https://api.bilibili.com/x/space/myinfo', 'method': 'GET', 'comment': '获取自己的信息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {}}
[BILIBILI_API][2025-11-24 16:34:43,121][INFO] 激活 buvid3 / buvid4 成功: 3 [2D05CC22-EFD6-3822-C4F8-1E57E5ADD0F982803infoc] 4 [FB51E329-0C43-C41F-37A2-111A6945A27482803-025112416-2bgwPqEuNGsJyZ1GP3M/SQ==]
[BILIBILI_API][2025-11-24 16:34:43,237][INFO] Api 获得响应: {'result': {'mid': 3546953428240801, 'name': '织羽酱哟', 'sex': '女', 'face': 'https://i1.hdslb.com/bfs/face/d6e054645d9fc407d4916991fbbdb55d47a81355.jpg', 'sign': '', 'rank': 10000, 'level': 2, 'jointime': 0, 'moral': 70, 'silence': 0, 'email_status': 0, 'tel_status': 1, 'identification': 0, 'vip': {'type': 0, 'status': 0, 'due_date': 0, 'vip_pay_type': 0, 'theme_type': 0, 'label': {'path': '', 'text': '', 'label_theme': '', 'text_color': '', 'bg_style': 0, 'bg_color': '', 'border_color': '', 'use_img_label': True, 'img_label_uri_hans': '', 'img_label_uri_hant': '', 'img_label_uri_hans_static': 'https://i0.hdslb.com/bfs/vip/d7b702ef65a976b20ed854cbd04cb9e27341bb79.png', 'img_label_uri_hant_static': 'https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/KJunwh19T5.png', 'label_id': 0, 'label_goto': None}, 'avatar_subscript': 0, 'nickname_color': '', 'role': 0, 'avatar_subscript_url': '', 'tv_vip_status': 0, 'tv_vip_pay_type': 0, 'tv_due_date': 0, 'avatar_icon': {'icon_resource': {}}, 'ott_info': {'vip_type': 0, 'pay_type': 0, 'pay_channel_id': '', 'status': 0, 'overdue_time': 0}, 'super_vip': {'is_super_vip': False}}, 'pendant': {'pid': 0, 'name': '', 'image': '', 'expire': 0, 'image_enhance': '', 'image_enhance_frame': '', 'n_pid': 0}, 'nameplate': {'nid': 0, 'name': '', 'image': '', 'image_small': '', 'level': '', 'condition': ''}, 'official': {'role': 0, 'title': '', 'desc': '', 'type': -1}, 'birthday': 315504000, 'is_tourist': 0, 'is_fake_account': 0, 'pin_prompting': 1, 'is_deleted': 0, 'in_reg_audit': 0, 'is_rip_user': False, 'profession': {'id': 0, 'name': '', 'show_name': '', 'is_show': 0, 'category_one': '', 'realname': '', 'title': '', 'department': '', 'certificate_no': '', 'certificate_show': False}, 'face_nft': 0, 'face_nft_new': 0, 'is_senior_member': 0, 'honours': {'mid': 3546953428240801, 'colour': {'dark': '#CE8620', 'normal': '#F0900B'}, 'tags': None, 'is_latest_100honour': 0}, 'digital_id': '', 'digital_type': -2, 'attestation': {'type': 0, 'common_info': {'title': '', 'prefix': '', 'prefix_title': ''}, 'splice_info': {'title': ''}, 'icon': '', 'desc': ''}, 'expert_info': {'title': '', 'state': 0, 'type': 0, 'desc': ''}, 'name_render': None, 'country_code': '86', 'handle': '', 'level_exp': {'current_level': 2, 'current_min': 200, 'current_exp': 850, 'next_exp': 1500, 'level_up': 1754466029}, 'coins': 83, 'following': 5, 'follower': 5}}
[BILIBILI_API][2025-11-24 16:34:43,237][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions', 'method': 'GET', 'comment': '获取已有消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'session_type': 4, 'group_fold': 1, 'unfollow_fold': 0, 'sort_rule': 2, 'build': 0, 'mobi_app': 'web'}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'session_type': 'int: 1: 私聊, 2: 通知, 3: 应援团, 4: 全部', 'group_fold': 'int: 默认为 1', 'unfollow_fold': 'int: 默认为 0', 'sort_rule': 'int: 默认为 2', 'build': 'int: 默认为 0', 'mobi_app': 'web'}}
[BILIBILI_API][2025-11-24 16:34:43,587][INFO] Api 获得响应: {'result': {'session_list': [{'talker_id': 626885218, 'session_type': 1, 'at_seqno': 0, 'top_ts': 0, 'group_name': '', 'group_cover': '', 'is_follow': 1, 'is_dnd': 0, 'ack_seqno': 2143087447486472, 'ack_ts': 1763433966746526, 'session_ts': 1763973101917253, 'unread_count': 6, 'last_msg': {'sender_uid': 626885218, 'receiver_type': 1, 'receiver_id': 3546953428240801, 'msg_type': 1, 'content': '{"content":"111"}', 'msg_seqno': 2152132631875595, 'timestamp': 1763973101, 'at_uids': None, 'msg_key': 7576206780669891263, 'msg_status': 0, 'notify_code': '', 'msg_source': 7}, 'group_type': 0, 'can_fold': 0, 'status': 0, 'max_seqno': 2152132631875595, 'new_push_msg': 0, 'setting': 0, 'is_guardian': 0, 'is_intercept': 0, 'is_trust': 0, 'system_msg_type': 0, 'live_status': 0, 'biz_msg_unread_count': 0, 'user_label': None}, {'talker_id': 589688100, 'session_type': 1, 'at_seqno': 0, 'top_ts': 0, 'group_name': '', 'group_cover': '', 'is_follow': 1, 'is_dnd': 0, 'ack_seqno': 2139423722450971, 'ack_ts': 1763468011590837, 'session_ts': 1763215591979435, 'unread_count': 0, 'last_msg': {'sender_uid': 589688100, 'receiver_type': 1, 'receiver_id': 3546953428240801, 'msg_type': 1, 'content': '{"content":"我们已互相关注,开始聊天吧~"}', 'msg_seqno': 2139423722450971, 'timestamp': 1763215591, 'at_uids': None, 'msg_key': 7572953300103807876, 'msg_status': 0, 'notify_code': '', 'msg_source': 17}, 'group_type': 0, 'can_fold': 0, 'status': 0, 'max_seqno': 2139423722450971, 'new_push_msg': 0, 'setting': 0, 'is_guardian': 0, 'is_intercept': 0, 'is_trust': 0, 'system_msg_type': 0, 'live_status': 0, 'biz_msg_unread_count': 0, 'user_label': None}, {'talker_id': 12076317, 'session_type': 1, 'at_seqno': 0, 'top_ts': 0, 'group_name': '', 'group_cover': '', 'is_follow': 0, 'is_dnd': 0, 'ack_seqno': 2133054470500357, 'ack_ts': 1762837101270705, 'session_ts': 1762835954661305, 'unread_count': 0, 'last_msg': {'sender_uid': 12076317, 'receiver_type': 1, 'receiver_id': 3546953428240801, 'msg_type': 10, 'content': '{"title":"登录操作通知","text":"你的账号在新设备或平台登录成功,如非本人操作,请及时修改密码(密码修改成功,全平台清空登录态)","jump_text":"查看详情","jump_uri":"https://account.bilibili.com/h5/account-h5/notice/notice-login?mid=3546953428240801\\u0026buvid=","modules":[{"title":"设备/平台","detail":"Edge浏览器"},{"title":"登录方式","detail":"扫码登录"},{"title":"参考登录地","detail":"中国浙江杭州"},{"title":"登录时间","detail":"2025-11-11 12:39:14"}],"jump_text_2":"","jump_uri_2":"","jump_text_3":"","jump_uri_3":"","notifier":null,"jump_uri_config":{"all_uri":"https://account.bilibili.com/h5/account-h5/notice/notice-login?mid=3546953428240801\\u0026buvid=","harmony_uri":"https://account.bilibili.com/h5/account-h5/notice/notice-login?mid=3546953428240801\\u0026buvid=","text":"查看详情"},"jump_uri_2_config":{"harmony_uri":"","text":""},"jump_uri_3_config":{"harmony_uri":"","text":""},"biz_content":null}', 'msg_seqno': 2133054470500357, 'timestamp': 1762835954, 'at_uids': None, 'msg_key': 7571322771205145915, 'msg_status': 0, 'notify_code': '3_13', 'msg_source': 6}, 'group_type': 0, 'can_fold': 1, 'status': 0, 'max_seqno': 2133054470500357, 'new_push_msg': 0, 'setting': 0, 'is_guardian': 0, 'is_intercept': 0, 'is_trust': 0, 'system_msg_type': 0, 'live_status': 0, 'biz_msg_unread_count': 0, 'user_label': None}, {'talker_id': 1880487363, 'session_type': 1, 'at_seqno': 0, 'top_ts': 0, 'group_name': '', 'group_cover': '', 'is_follow': 1, 'is_dnd': 0, 'ack_seqno': 2027373495328772, 'ack_ts': 1756537262788294, 'session_ts': 1756536877248047, 'unread_count': 0, 'last_msg': {'sender_uid': 1880487363, 'receiver_type': 1, 'receiver_id': 3546953428240801, 'msg_type': 1, 'content': '{"content":"感谢关注Neuro21烤肉组,希望您喜欢我们的切片,有什么建议和想看的可以在评论区或私信提出!<3<3<3"}', 'msg_seqno': 2027373495328772, 'timestamp': 1756536877, 'at_uids': None, 'msg_key': 7544268441029871954, 'msg_status': 0, 'notify_code': '', 'msg_source': 8}, 'group_type': 0, 'can_fold': 0, 'status': 0, 'max_seqno': 2027373495328772, 'new_push_msg': 0, 'setting': 0, 'is_guardian': 0, 'is_intercept': 0, 'is_trust': 0, 'system_msg_type': 0, 'live_status': 0, 'biz_msg_unread_count': 0, 'user_label': None}, {'talker_id': 482294757, 'session_type': 1, 'at_seqno': 0, 'top_ts': 0, 'group_name': '', 'group_cover': '', 'is_follow': 1, 'is_dnd': 0, 'ack_seqno': 2025917803851794, 'ack_ts': 1761490799737422, 'session_ts': 1756450112014345, 'unread_count': 0, 'last_msg': {'sender_uid': 482294757, 'receiver_type': 1, 'receiver_id': 3546953428240801, 'msg_type': 1, 'content': '{"content":"我们已互相关注,开始聊天吧~"}', 'msg_seqno': 2025917803851794, 'timestamp': 1756450111, 'at_uids': None, 'msg_key': 7543895784799687015, 'msg_status': 0, 'notify_code': '', 'msg_source': 17}, 'group_type': 0, 'can_fold': 0, 'status': 0, 'max_seqno': 2025917803851794, 'new_push_msg': 0, 'setting': 0, 'is_guardian': 0, 'is_intercept': 0, 'is_trust': 0, 'system_msg_type': 0, 'live_status': 0, 'biz_msg_unread_count': 0, 'user_label': None}], 'has_more': 0, 'anti_disturb_cleaning': False, 'is_address_list_empty': 0, 'show_level': False}}
[2025-11-24 16:34:43][INFO]: 开始轮询
[BILIBILI_API][2025-11-24 16:34:43,596][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/session_svr/v1/session_svr/new_sessions', 'method': 'GET', 'comment': '获取新消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'begin_ts': 1763973282684367, 'build': 0, 'mobi_app': 'web'}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'begin_ts': 'int: 起始时间戳'}}
[BILIBILI_API][2025-11-24 16:34:43,716][INFO] Api 获得响应: {'result': {'session_list': None, 'has_more': 0, 'anti_disturb_cleaning': False, 'is_address_list_empty': 0, 'show_level': False}}
[BILIBILI_API][2025-11-24 16:34:49,592][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/session_svr/v1/session_svr/new_sessions', 'method': 'GET', 'comment': '获取新消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'begin_ts': 1763973282684367, 'build': 0, 'mobi_app': 'web'}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'begin_ts': 'int: 起始时间戳'}}
[BILIBILI_API][2025-11-24 16:34:49,939][INFO] Api 获得响应: {'result': {'session_list': [{'talker_id': 626885218, 'session_type': 1, 'at_seqno': 0, 'top_ts': 0, 'group_name': '', 'group_cover': '', 'is_follow': 1, 'is_dnd': 0, 'ack_seqno': 2143087447486472, 'ack_ts': 1763433966746526, 'session_ts': 1763973289244407, 'unread_count': 7, 'last_msg': {'sender_uid': 626885218, 'receiver_type': 1, 'receiver_id': 3546953428240801, 'msg_type': 1, 'content': '{"content":"测试消息"}', 'msg_seqno': 2152135785979907, 'timestamp': 1763973289, 'at_uids': None, 'msg_key': 7576207587400168354, 'msg_status': 0, 'notify_code': '', 'msg_source': 7}, 'group_type': 0, 'can_fold': 0, 'status': 0, 'max_seqno': 2152135785979907, 'new_push_msg': 0, 'setting': 0, 'is_guardian': 0, 'is_intercept': 0, 'is_trust': 0, 'system_msg_type': 0, 'live_status': 0, 'biz_msg_unread_count': 0, 'user_label': None}], 'has_more': 0, 'anti_disturb_cleaning': False, 'is_address_list_empty': 0, 'show_level': False}}
[BILIBILI_API][2025-11-24 16:34:49,939][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs', 'method': 'GET', 'comment': '获取指定用户的近三十条消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'talker_id': 626885218, 'session_type': 1, 'begin_seqno': 2152132631875595}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'talker_id': 'int: 私聊时为用户UID 应援团时为团号', 'session_type': 'int: 会话类型,1 私聊 2 应援团', 'begin_seqno': 'int: 起始 Seqno 可由具体消息获得'}}
[BILIBILI_API][2025-11-24 16:34:50,068][INFO] Api 获得响应: {'result': {'messages': None, 'has_more': 1, 'min_seqno': 18446744073709551615, 'max_seqno': 0}}
[2025-11-24 16:34:50][DEBUG]: maxTs = 1763973289244407
[BILIBILI_API][2025-11-24 16:34:55,603][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/session_svr/v1/session_svr/new_sessions', 'method': 'GET', 'comment': '获取新消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'begin_ts': 1763973289244407, 'build': 0, 'mobi_app': 'web'}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'begin_ts': 'int: 起始时间戳'}}
[BILIBILI_API][2025-11-24 16:34:55,938][INFO] Api 获得响应: {'result': {'session_list': None, 'has_more': 0, 'anti_disturb_cleaning': False, 'is_address_list_empty': 0, 'show_level': False}}
[BILIBILI_API][2025-11-24 16:35:01,592][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/session_svr/v1/session_svr/new_sessions', 'method': 'GET', 'comment': '获取新消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'begin_ts': 1763973289244407, 'build': 0, 'mobi_app': 'web'}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'begin_ts': 'int: 起始时间戳'}}
[BILIBILI_API][2025-11-24 16:35:01,827][INFO] Api 获得响应: {'result': {'session_list': None, 'has_more': 0, 'anti_disturb_cleaning': False, 'is_address_list_empty': 0, 'show_level': False}}
[BILIBILI_API][2025-11-24 16:35:07,603][INFO] Api 发起请求: {'url': 'https://api.vc.bilibili.com/session_svr/v1/session_svr/new_sessions', 'method': 'GET', 'comment': '获取新消息', 'wbi': False, 'wbi2': False, 'verify': True, 'no_csrf': False, 'json_body': False, 'ignore_code': False, 'sign': False, 'data': {}, 'params': {'begin_ts': 1763973289244407, 'build': 0, 'mobi_app': 'web'}, 'files': {}, 'headers': {}, 'credential': <bilibili_api.utils.network.Credential object at 0x0000022695DC3EB0>, 'original_data': {}, 'original_params': {'begin_ts': 'int: 起始时间戳'}}
[BILIBILI_API][2025-11-24 16:35:07,980][INFO] Api 获得响应: {'result': {'session_list': None, 'has_more': 0, 'anti_disturb_cleaning': False, 'is_address_list_empty': 0, 'show_level': False}}
Metadata
Metadata
Assignees
Labels
question这啥呀这是,我不到啊这啥呀这是,我不到啊