fix invalid card number handler

This commit is contained in:
timka 2024-01-08 20:41:34 +03:00
parent 347db3a8e0
commit eda0f959dd

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)