Make commands async and improve error handling

This commit is contained in:
2022-06-01 09:09:10 +01:00
parent 6aec0c1078
commit 67ed68ac5e
2 changed files with 15 additions and 8 deletions

View File

@@ -887,15 +887,19 @@ class IRCCommands(object):
authed = True
helptext = "Enable an account_id at a bank for use in Nordigen. Usage: nmapaccount <account_id>"
@staticmethod
def got_map_account(account_name, account_id, msg):
if not account_name:
msg(f"Failed to map the account")
return
msg(f"Mapped account ID {account_id} to {account_name}")
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 2:
account_id = spl[1]
account_name = tx.sinks.nordigen.map_account(account_id)
if not account_name:
msg(f"Failed to map the account")
return
msg(f"Mapped account ID {account_id} to {account_name}")
c = tx.sinks.nordigen.map_account(account_id)
c.addCallback(IRCCommands.nmapaccount.got_map_account, account_id, msg)
class nunmapaccount(object):
name = "nunmapaccount"