Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(login): add qr onekey login hook #270

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Qzone3TG"
version = "0.9.5.dev10"
version = "0.9.5.dev11"
description = "Forward Qzone feeds to telegram."
authors = ["aioqzone <zzzzss990315@gmail.com>"]
readme = "README.md"
Expand Down
48 changes: 30 additions & 18 deletions src/qzone3tg/app/interact/_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,41 @@ def _as_inputfile(b: bytes):
return BufferedInputFile(b, "login_qrcode.png")

@self.login.qr.qr_fetched.add_impl
async def QrFetched(png: bytes, times: int, qr_renew=False):
async def QrFetched(png: bytes | None, times: int, qr_renew=False):
nonlocal qr_msg
inlinekb = self._make_qr_markup()

if qr_msg is None:
qr_msg = await self.bot.send_photo(
self.admin,
_as_inputfile(png),
caption="扫码登陆:",
disable_notification=False,
reply_markup=self._make_qr_markup(),
)
if png is None:
qr_msg = await self.bot.send_message(
self.admin,
text="二维码已推送到您的QQ手机端,请确认登录。",
disable_notification=False,
reply_markup=inlinekb,
)
else:
qr_msg = await self.bot.send_photo(
self.admin,
_as_inputfile(png),
caption="请扫码登陆",
disable_notification=False,
reply_markup=inlinekb,
)
return

if qr_renew:
# TODO: qr_renew
text = f"二维码已刷新[{times}]"
else:
text = f"二维码已过期, 请重新扫描[{times}]"
if qr_renew:
# TODO: qr_renew
text = f"二维码已刷新[{times}]"
qr_renew = False

msg = await self.bot.edit_message_media(
if png is None:
msg = await qr_msg.edit_text(text, reply_markup=inlinekb)
else:
msg = qr_msg.edit_media(
InputMediaPhoto(media=_as_inputfile(png), caption=text),
self.admin,
qr_msg.message_id,
reply_markup=self._make_qr_markup(),
reply_markup=inlinekb,
)
if isinstance(msg, Message):
qr_msg = msg

if isinstance(msg, Message):
qr_msg = msg