Make more commands async

This commit is contained in:
Mark Veidemanis 2022-06-14 08:44:29 +01:00
parent 74f5fca9ab
commit 38dbd5a3f9
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 30 additions and 6 deletions

View File

@ -689,60 +689,84 @@ class IRCCommands(object):
authed = True authed = True
helptext = "Show how much is left before we are able to withdraw funds." helptext = "Show how much is left before we are able to withdraw funds."
@staticmethod
def got_remaining(data_remaining, msg):
msg(f"Remaining: {data_remaining}USD")
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux): def run(cmd, spl, length, authed, msg, agora, tx, ux):
remaining = tx.money.get_remaining() remaining = tx.money.get_remaining()
msg(f"Remaining: {remaining}USD") remaining.addCallback(IRCCommands.remaining.got_remaining, msg)
class total_remaining(object): class total_remaining(object):
name = "tr" name = "tr"
authed = True authed = True
helptext = "Show how much is left before we are able to withdraw funds (including open trades)." helptext = "Show how much is left before we are able to withdraw funds (including open trades)."
@staticmethod
def got_total_remaining(data_remaining, msg):
msg(f"Total remaining: {data_remaining}USD")
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux): def run(cmd, spl, length, authed, msg, agora, tx, ux):
remaining = tx.money.get_total_remaining() remaining = tx.money.get_total_remaining()
msg(f"Total remaining: {remaining}USD") remaining.addCallback(IRCCommands.total_remaining.got_total_remaining, msg)
class tradetotal(object): class tradetotal(object):
name = "tradetotal" name = "tradetotal"
authed = True authed = True
helptext = "Get total value of all open trades in USD." helptext = "Get total value of all open trades in USD."
@staticmethod
def got_tradetotal(data_tradetotal, msg):
msg(f"Total trades: {data_tradetotal}USD")
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux): def run(cmd, spl, length, authed, msg, agora, tx, ux):
total = tx.money.get_open_trades_usd() total = tx.money.get_open_trades_usd()
msg(f"Total trades: {total}USD") total.addCallback(IRCCommands.tradetotal.got_tradetotal, msg)
class dollar(object): class dollar(object):
name = "$" name = "$"
authed = True authed = True
helptext = "Get total value of everything, including open trades." helptext = "Get total value of everything, including open trades."
@staticmethod
def got_dollar(data_dollar, msg):
msg(f"${data_dollar}")
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux): def run(cmd, spl, length, authed, msg, agora, tx, ux):
total = tx.money.get_total_with_trades() total = tx.money.get_total_with_trades()
msg(f"${total}") total.addCallback(IRCCommands.dollar.got_dollar, msg)
class profit(object): class profit(object):
name = "profit" name = "profit"
authed = True authed = True
helptext = "Get total profit." helptext = "Get total profit."
@staticmethod
def got_profit(data_profit, msg):
msg(f"Profit: {data_profit}USD")
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux): def run(cmd, spl, length, authed, msg, agora, tx, ux):
total = tx.money.get_profit() total = tx.money.get_profit()
msg(f"Profit: {total}USD") total.addCallback(IRCCommands.profit.got_profit, msg)
class tprofit(object): class tprofit(object):
name = "tprofit" name = "tprofit"
authed = True authed = True
helptext = "Get total profit with open trades." helptext = "Get total profit with open trades."
@staticmethod
def got_tprofit(data_tprofit, msg):
msg(f"Total profit: {data_tprofit}USD")
@staticmethod @staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux): def run(cmd, spl, length, authed, msg, agora, tx, ux):
total = tx.money.get_profit(True) total = tx.money.get_profit(True)
msg(f"Profit: {total}USD") total.addCallback(IRCCommands.tprofit.got_tprofit, msg)
class signin(object): class signin(object):
name = "signin" name = "signin"