save get property to fix exception during telegram nessaging
This commit is contained in:
parent
527229272b
commit
93529317cd
@ -787,14 +787,19 @@ async def list_initial_wallet_states():
|
|||||||
f"{chr(10).join(your_wallet_state)}\n"
|
f"{chr(10).join(your_wallet_state)}\n"
|
||||||
f"<b>Total Value:</b> {YOUR_WALLET_VALUE:.2f} {DISPLAY_CURRENCY}\n\n"
|
f"<b>Total Value:</b> {YOUR_WALLET_VALUE:.2f} {DISPLAY_CURRENCY}\n\n"
|
||||||
f"<b>Monitored Tokens:</b>\n"
|
f"<b>Monitored Tokens:</b>\n"
|
||||||
f"{', '.join([info['name'] for info in TOKEN_ADDRESSES.values()])}"
|
f"{', '.join([safe_get_property(info, 'name') for info in TOKEN_ADDRESSES.values()])}"
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info(message)
|
logging.info(message)
|
||||||
await send_telegram_message(message)
|
await send_telegram_message(message)
|
||||||
|
|
||||||
# save token info to file
|
# save token info to file
|
||||||
await save_token_info()
|
await save_token_info()
|
||||||
|
|
||||||
|
def safe_get_property(info, property_name, default='Unknown'):
|
||||||
|
return info.get(property_name, default) if isinstance(info, dict) else default
|
||||||
|
|
||||||
|
|
||||||
async def save_token_info():
|
async def save_token_info():
|
||||||
with open('./logs/token_info.json', 'w') as f:
|
with open('./logs/token_info.json', 'w') as f:
|
||||||
json.dump(TOKENS_INFO, f, indent=2)
|
json.dump(TOKENS_INFO, f, indent=2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user