QR 登录与 QrSession¶
- class qqqr.qr.QrSession(first_qr, login_sig, *, create_time=None, refresh_times=0)¶
QR 登录的 session 状态。
跟踪二维码刷新次数、过期时间和当前二维码图片。
- refreshed¶
二维码刷新次数计数器。
- new_qr(qr)¶
向此 session 添加一个新的二维码。
- class qqqr.qr.QrLogin(client, uin, h5=True, app=None, proxy=None, info=None, *args, **kwds)¶
- async new(no_push=False)¶
创建一个
QrSession。此方法将:GET
xloginURL 以获取pt_login_sigcookie;Try "quick login" (the QR code is pushed to user's client);
在 1.8.3 版本发生变更: 添加了
no_push参数。
- async poll(sess)¶
轮询二维码状态。
- 抛出:
aiohttp.ClientResponseError -- 如果响应状态码 != 200
- 返回类型:
- 返回:
一个轮询响应对象
- async login(*, refresh_times=6, poll_freq=3, no_push=False)¶
循环直到获取到 cookie 或超过最大
refresh_times次数。此方法在获取到新二维码时会触发
qr_fetched事件。如果二维码在
refresh_times次后仍未扫描,将引发UserTimeout。如果设置了
refresh,将立即刷新二维码而不增加过期计数器。如果设置了
cancel,将在下次轮询前引发UserBreak。
- 参数:
- 抛出:
UserTimeout -- 如果二维码在
refresh_times次过期后仍未扫描。UserBreak -- 如果设置了
cancel。
在 1.8.3 版本发生变更: 添加了
no_push参数。