QrLogin and QrSession¶
- class qqqr.qr.QR(png, sig, expired=False)¶
Class
QR
represents a QR code.- property pushed¶
Whether the QR code is pushed to user’s client.
- class qqqr.qr.QrSession(first_qr, login_sig, *, create_time=None, refresh_times=0)¶
- refreshed¶
QR code refresh times counter.
- new_qr(qr)¶
Add a new QR code to this session.
- class qqqr.qr.QrLogin(client, uin, h5=True, app=None, proxy=None, info=None, *args, **kwds)¶
- async new(no_push=False)¶
Create a
QrSession
. This method will:GET
xlogin
url to getpt_login_sig
cookie;Try “quick login” (the QR code is pushed to user’s client);
Whether the QR code is pushed or not, a
QR
object is created and is hold by the returnedQrSession
.
在 1.8.3 版本发生变更: Added
no_push
param.
- async show(push_qr=False)¶
This method will call
ptqrshow
api and wrap the response QR bytes intoQR
.
- async poll(sess)¶
Poll QR status.
- 抛出:
aiohttp.ClientResponseError – if response status code != 200
- 返回类型:
- 返回:
a poll response object
- async login(*, refresh_times=6, poll_freq=3, no_push=False)¶
Loop until cookie is returned or max
refresh_times
exceeds.This method will emit
qr_fetched
event if a new qrcode is fetched.If the QR code is not scanned after
refresh_times
, it will raiseUserTimeout
.If
refresh
is set, it will refresh qrcode at once without increasing expire counter.If
cancel
is set, it will raiseUserBreak
before next polling.
- 参数:
- 抛出:
UserTimeout – if the QR code is not scanned after
refresh_times
expires.UserBreak – if
cancel
is set.
在 1.8.3 版本发生变更: Added
no_push
param.