Skip to content

Commit

Permalink
fix: Handle qr code expired
Browse files Browse the repository at this point in the history
Fixes HOYO-BUDDY-55
  • Loading branch information
seriaati committed Jun 4, 2024
1 parent 403a8c9 commit 73a10c8
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions hoyo_buddy/ui/account/items/with_qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,25 @@ async def callback(self, i: INTERACTION) -> Any:

scanned = False
while True:
check_result = await client._check_qrcode(
result.app_id, result.device_id, result.ticket
)
try:
check_result = await client._check_qrcode(
result.app_id, result.device_id, result.ticket
)
except genshin.GenshinException as e:
if e.retcode == -106:
# QR code expired
return await i.edit_original_response(
embed=DefaultEmbed(
self.view.locale,
self.view.translator,
title=LocaleStr("QR code expired", key="qrcode_expired_title"),
description=LocaleStr(
"Please try again with a new QR code", key="qrcode_expired.desc"
),
),
attachments=[],
)
raise
if check_result.status is genshin.models.QRCodeStatus.SCANNED and not scanned:
await i.edit_original_response(embed=self._scanned_embed, attachments=[])
scanned = True
Expand Down

0 comments on commit 73a10c8

Please sign in to comment.