fix invalid card number handler

master
timka 2024-01-08 20:41:34 +03:00
parent 347db3a8e0
commit eda0f959dd
1 changed files with 4 additions and 1 deletions

View File

@ -16,7 +16,10 @@ async def tk_balance(card_number: int):
file = open("temp.xml", "w+")
file.write(text)
file.close()
balance = ElementTree.parse("temp.xml").findtext(".//pbtext").replace("Билет длительного пользования", "").replace(" руб.", "")
try:
balance = ElementTree.parse("temp.xml").findtext(".//pbtext").replace("Билет длительного пользования", "").replace(" руб.", "")
except AttributeError:
return
if not balance:
return
return int(balance)