Skip to content

Commit

Permalink
feat(login): add qr onekey login hook
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Nov 29, 2023
1 parent 5dac334 commit 992ee5d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
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

0 comments on commit 992ee5d

Please sign in to comment.