Fix trades command
This commit is contained in:
parent
4db63998a1
commit
bd48bf37f5
|
@ -47,10 +47,7 @@ class Agora(object):
|
|||
self.lc_dash = LoopingCall(self.loop_check)
|
||||
self.lc_dash.start(int(settings.Agora.RefreshSec))
|
||||
|
||||
def loop_check(self):
|
||||
"""
|
||||
Calls hooks to parse dashboard info and get all contact messages.
|
||||
"""
|
||||
def wrap_dashboard(self):
|
||||
try:
|
||||
dash = self.agora.dashboard_seller()
|
||||
except ReadTimeout:
|
||||
|
@ -58,11 +55,18 @@ class Agora(object):
|
|||
dash_tmp = {}
|
||||
if "data" not in dash["response"].keys():
|
||||
self.log.error("Data not in dashboard response: {content}", content=dash)
|
||||
return False
|
||||
return dash_tmp
|
||||
if dash["response"]["data"]["contact_count"] > 0:
|
||||
for contact in dash["response"]["data"]["contact_list"]:
|
||||
contact_id = contact["data"]["contact_id"]
|
||||
dash_tmp[contact_id] = contact
|
||||
return dash_tmp
|
||||
|
||||
def loop_check(self):
|
||||
"""
|
||||
Calls hooks to parse dashboard info and get all contact messages.
|
||||
"""
|
||||
dash_tmp = self.wrap_dashboard()
|
||||
|
||||
# Call dashboard hooks
|
||||
self.dashboard_hook(dash_tmp)
|
||||
|
@ -78,8 +82,20 @@ class Agora(object):
|
|||
"""
|
||||
Get dashboard helper for IRC only.
|
||||
"""
|
||||
# dash_tmp.append(f"{reference}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
||||
pass
|
||||
dash = self.wrap_dashboard()
|
||||
rtrn = []
|
||||
if not dash.items():
|
||||
return
|
||||
for contact_id, contact in dash.items():
|
||||
reference = self.tx.tx_to_ref(contact_id)
|
||||
buyer = contact["data"]["buyer"]["username"]
|
||||
amount = contact["data"]["amount"]
|
||||
amount_xmr = contact["data"]["amount_xmr"]
|
||||
currency = contact["data"]["currency"]
|
||||
if not contact["data"]["is_selling"]:
|
||||
continue
|
||||
rtrn.append(f"{reference}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
||||
return rtrn
|
||||
|
||||
def dashboard_hook(self, dash):
|
||||
"""
|
||||
|
|
|
@ -16,7 +16,7 @@ class IRCCommands(object):
|
|||
# Send IRC - we don't want to automatically send messages on IRC, even though
|
||||
# this variable seems counter-intuitive here, we are doing something with the result
|
||||
# then calling msg() ourselves, and we don't want extra spam in the channel.
|
||||
trades = agora.dashboard(send_irc=False)
|
||||
trades = agora.get_dashboard()
|
||||
if not trades:
|
||||
msg("No open trades.")
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue