Add error handling in commands
This commit is contained in:
parent
3340b6d4da
commit
535f890554
|
@ -13,8 +13,12 @@ class IRCCommands(object):
|
||||||
Get details of open trades and post on IRC.
|
Get details of open trades and post on IRC.
|
||||||
"""
|
"""
|
||||||
trades = agora.dashboard(send_irc=False)
|
trades = agora.dashboard(send_irc=False)
|
||||||
|
if trades is False:
|
||||||
|
msg("Error getting trades.")
|
||||||
|
return
|
||||||
if not trades:
|
if not trades:
|
||||||
msg("No open trades.")
|
msg("No open trades.")
|
||||||
|
return
|
||||||
for trade_id in trades:
|
for trade_id in trades:
|
||||||
msg(trade_id)
|
msg(trade_id)
|
||||||
|
|
||||||
|
@ -44,8 +48,12 @@ class IRCCommands(object):
|
||||||
"""
|
"""
|
||||||
if length == 1:
|
if length == 1:
|
||||||
messages = agora.get_all_messages(send_irc=False)
|
messages = agora.get_all_messages(send_irc=False)
|
||||||
|
if messages is False:
|
||||||
|
msg("Error getting messages.")
|
||||||
|
return
|
||||||
if not messages:
|
if not messages:
|
||||||
msg("No messages.")
|
msg("No messages.")
|
||||||
|
return
|
||||||
for message_id in messages:
|
for message_id in messages:
|
||||||
for message in messages[message_id]:
|
for message in messages[message_id]:
|
||||||
msg(f"{message_id}: {message}")
|
msg(f"{message_id}: {message}")
|
||||||
|
@ -96,9 +104,15 @@ class IRCCommands(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(cmd, spl, length, authed, msg, agora, revolut, tx):
|
def run(cmd, spl, length, authed, msg, agora, revolut, tx):
|
||||||
accounts = revolut.accounts()
|
accounts = revolut.accounts()
|
||||||
|
accounts_posted = 0
|
||||||
|
if accounts is None:
|
||||||
|
msg("Error getting accounts.")
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
if account["balance"] > 0:
|
if account["balance"] > 0:
|
||||||
msg(f"{account['name']} {account['currency']}: {account['balance']}")
|
msg(f"{account['name']} {account['currency']}: {account['balance']}")
|
||||||
|
accounts_posted += 1
|
||||||
|
if accounts_posted == 0:
|
||||||
|
msg("No accounts with balances.")
|
||||||
|
|
||||||
class total(object):
|
class total(object):
|
||||||
name = "total"
|
name = "total"
|
||||||
|
|
Loading…
Reference in New Issue