Finish implementation and tests for the cheat system #3
|
@ -47,10 +47,7 @@ class Agora(object):
|
||||||
self.lc_dash = LoopingCall(self.loop_check)
|
self.lc_dash = LoopingCall(self.loop_check)
|
||||||
self.lc_dash.start(int(settings.Agora.RefreshSec))
|
self.lc_dash.start(int(settings.Agora.RefreshSec))
|
||||||
|
|
||||||
def loop_check(self):
|
def wrap_dashboard(self):
|
||||||
"""
|
|
||||||
Calls hooks to parse dashboard info and get all contact messages.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
dash = self.agora.dashboard_seller()
|
dash = self.agora.dashboard_seller()
|
||||||
except ReadTimeout:
|
except ReadTimeout:
|
||||||
|
@ -58,11 +55,18 @@ class Agora(object):
|
||||||
dash_tmp = {}
|
dash_tmp = {}
|
||||||
if "data" not in dash["response"].keys():
|
if "data" not in dash["response"].keys():
|
||||||
self.log.error("Data not in dashboard response: {content}", content=dash)
|
self.log.error("Data not in dashboard response: {content}", content=dash)
|
||||||
return False
|
return dash_tmp
|
||||||
if dash["response"]["data"]["contact_count"] > 0:
|
if dash["response"]["data"]["contact_count"] > 0:
|
||||||
for contact in dash["response"]["data"]["contact_list"]:
|
for contact in dash["response"]["data"]["contact_list"]:
|
||||||
contact_id = contact["data"]["contact_id"]
|
contact_id = contact["data"]["contact_id"]
|
||||||
dash_tmp[contact_id] = contact
|
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
|
# Call dashboard hooks
|
||||||
self.dashboard_hook(dash_tmp)
|
self.dashboard_hook(dash_tmp)
|
||||||
|
@ -78,8 +82,20 @@ class Agora(object):
|
||||||
"""
|
"""
|
||||||
Get dashboard helper for IRC only.
|
Get dashboard helper for IRC only.
|
||||||
"""
|
"""
|
||||||
# dash_tmp.append(f"{reference}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
dash = self.wrap_dashboard()
|
||||||
pass
|
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):
|
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
|
# 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
|
# 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.
|
# 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:
|
if not trades:
|
||||||
msg("No open trades.")
|
msg("No open trades.")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue