Fix dashboard stuff
This commit is contained in:
parent
f8521eced3
commit
2bf05eafa7
|
@ -44,7 +44,6 @@ class Agora(util.Base):
|
|||
"""
|
||||
Set up the LoopingCall to get all active trades and messages.
|
||||
"""
|
||||
self.loop_check()
|
||||
self.log.debug("Setting up loops.")
|
||||
self.lc_dash = LoopingCall(self.loop_check)
|
||||
self.lc_dash.start(int(settings.Agora.RefreshSec))
|
||||
|
@ -66,8 +65,8 @@ class Agora(util.Base):
|
|||
return False
|
||||
if dash is False:
|
||||
return False
|
||||
if dash["response"] is None:
|
||||
return False
|
||||
# if dash["response"] is None:
|
||||
# return False
|
||||
dash_tmp = {}
|
||||
if not dash.items():
|
||||
return False
|
||||
|
@ -91,11 +90,12 @@ class Agora(util.Base):
|
|||
m = self.agora.recent_messages()
|
||||
m.addCallback(self.got_recent_messages)
|
||||
|
||||
@inlineCallbacks
|
||||
def get_dashboard_irc(self):
|
||||
"""
|
||||
Get dashboard helper for IRC only.
|
||||
"""
|
||||
dash = self.wrap_dashboard()
|
||||
dash = yield self.wrap_dashboard()
|
||||
rtrn = []
|
||||
if dash is False:
|
||||
return False
|
||||
|
@ -112,7 +112,12 @@ class Agora(util.Base):
|
|||
provider = contact["data"]["advertisement"]["payment_method"]
|
||||
if not contact["data"]["is_selling"]:
|
||||
continue
|
||||
rtrn.append(f"{reference}: {buyer} {amount}{currency} {provider} {amount_crypto}{asset}")
|
||||
rtrn.append(
|
||||
(
|
||||
f"[#] [{reference}] ({self.platform}) <{buyer}>"
|
||||
f" {amount}{currency} {provider} {amount_crypto}{asset}"
|
||||
)
|
||||
)
|
||||
return rtrn
|
||||
|
||||
def dashboard_hook(self, dash):
|
||||
|
@ -142,7 +147,7 @@ class Agora(util.Base):
|
|||
continue
|
||||
if reference not in self.last_dash:
|
||||
reference = self.tx.new_trade(
|
||||
"agora",
|
||||
self.platform,
|
||||
asset,
|
||||
contact_id,
|
||||
buyer,
|
||||
|
@ -155,7 +160,12 @@ class Agora(util.Base):
|
|||
if reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
# Let us know there is a new trade
|
||||
self.irc.sendmsg(f"AUTO {reference}: {buyer} {amount}{currency} {provider} {amount_crypto}{asset}")
|
||||
self.irc.sendmsg(
|
||||
(
|
||||
f"[#] [{reference}] ({self.platform}) <{buyer}>"
|
||||
f" {amount}{currency} {provider} {amount_crypto}{asset}"
|
||||
)
|
||||
)
|
||||
# Note that we have seen this reference
|
||||
self.last_dash.add(reference)
|
||||
|
||||
|
@ -165,7 +175,7 @@ class Agora(util.Base):
|
|||
self.last_dash.remove(ref)
|
||||
if reference and reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
self.tx.cleanup(current_trades)
|
||||
self.tx.cleanup(self.platform, current_trades)
|
||||
|
||||
def got_recent_messages(self, messages, send_irc=True):
|
||||
"""
|
||||
|
@ -194,16 +204,16 @@ class Agora(util.Base):
|
|||
|
||||
# Send new messages on IRC
|
||||
if send_irc:
|
||||
for user, message in messages_tmp[reference]:
|
||||
for user, message in messages_tmp[reference][::-1]:
|
||||
if reference in self.last_messages:
|
||||
if not [user, message] in self.last_messages[reference]:
|
||||
self.irc.sendmsg(f"AUTO {reference}: ({user}) {message}")
|
||||
self.irc.sendmsg(f"[{reference}] ({self.platform}) <{user}> {message}")
|
||||
# Append sent messages to last_messages so we don't send them again
|
||||
self.last_messages[reference].append([user, message])
|
||||
else:
|
||||
self.last_messages[reference] = [[user, message]]
|
||||
for x in messages_tmp[reference]:
|
||||
self.irc.sendmsg(f"NEW {reference}: ({user}) {message}")
|
||||
self.irc.sendmsg(f"[{reference}] ({self.platform}) <{user}> {message}")
|
||||
|
||||
# Purge old trades from cache
|
||||
for ref in list(self.last_messages): # We're removing from the list on the fly
|
||||
|
@ -349,7 +359,7 @@ class Agora(util.Base):
|
|||
return False
|
||||
|
||||
# Get the ads to update
|
||||
to_update = self.markets.get_new_ad_equations("agora", public_ads, assets)
|
||||
to_update = self.markets.get_new_ad_equations(self.platform, public_ads, assets)
|
||||
self.slow_ad_update(to_update)
|
||||
|
||||
# TODO: make generic and move to markets
|
||||
|
@ -417,7 +427,7 @@ class Agora(util.Base):
|
|||
cast["type"] = msgtype
|
||||
cast["ts"] = str(datetime.now().isoformat())
|
||||
cast["xtype"] = "platorm"
|
||||
cast["market"] = "agora"
|
||||
cast["market"] = self.platform
|
||||
self.es.index(index=settings.ES.MetaIndex, document=cast)
|
||||
|
||||
def slow_ad_update(self, ads):
|
||||
|
|
|
@ -44,8 +44,6 @@ class LBTC(util.Base):
|
|||
"""
|
||||
Set up the LoopingCall to get all active trades and messages.
|
||||
"""
|
||||
self.log.debug("Running loop check.")
|
||||
self.loop_check()
|
||||
self.log.debug("Setting up loops.")
|
||||
self.lc_dash = LoopingCall(self.loop_check)
|
||||
self.lc_dash.start(int(settings.LocalBitcoins.RefreshSec))
|
||||
|
@ -59,16 +57,16 @@ class LBTC(util.Base):
|
|||
dash_tmp = yield self.wrap_dashboard(dash)
|
||||
self.dashboard_hook(dash_tmp)
|
||||
|
||||
@util.handle_exceptions
|
||||
@inlineCallbacks
|
||||
def wrap_dashboard(self, dash=None): # backwards compatibility with TX
|
||||
if not dash:
|
||||
dash = self.lbtc.dashboard() # no dashboard_seller for lbtc
|
||||
dash = yield self.lbtc.dashboard() # no dashboard_seller for lbtc
|
||||
if dash is None:
|
||||
return False
|
||||
if dash is False:
|
||||
return False
|
||||
if dash["response"] is None:
|
||||
return False
|
||||
# if dash["response"] is None:
|
||||
# return False
|
||||
dash_tmp = {}
|
||||
if not dash.items():
|
||||
return False
|
||||
|
@ -92,11 +90,12 @@ class LBTC(util.Base):
|
|||
m = self.lbtc.recent_messages()
|
||||
m.addCallback(self.got_recent_messages)
|
||||
|
||||
@inlineCallbacks
|
||||
def get_dashboard_irc(self):
|
||||
"""
|
||||
Get dashboard helper for IRC only.
|
||||
"""
|
||||
dash = self.wrap_dashboard()
|
||||
dash = yield self.wrap_dashboard()
|
||||
rtrn = []
|
||||
if dash is False:
|
||||
return False
|
||||
|
@ -111,8 +110,13 @@ class LBTC(util.Base):
|
|||
provider = contact["data"]["advertisement"]["payment_method"]
|
||||
if not contact["data"]["is_selling"]:
|
||||
continue
|
||||
rtrn.append(f"{reference}: {buyer} {amount}{currency} {provider} {amount_crypto}{asset}")
|
||||
return rtrn
|
||||
rtrn.append(
|
||||
(
|
||||
f"[#] [{reference}] ({self.platform}) <{buyer}>"
|
||||
f" {amount}{currency} {provider} {amount_crypto}{asset}"
|
||||
)
|
||||
)
|
||||
return rtrn
|
||||
|
||||
def dashboard_hook(self, dash):
|
||||
"""
|
||||
|
@ -139,7 +143,7 @@ class LBTC(util.Base):
|
|||
continue
|
||||
if reference not in self.last_dash:
|
||||
reference = self.tx.new_trade(
|
||||
"lbtc",
|
||||
self.platform,
|
||||
asset,
|
||||
contact_id,
|
||||
buyer,
|
||||
|
@ -152,17 +156,21 @@ class LBTC(util.Base):
|
|||
if reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
# Let us know there is a new trade
|
||||
self.irc.sendmsg(f"AUTO {reference}: {buyer} {amount}{currency} {provider} {amount_crypto}{asset}")
|
||||
self.irc.sendmsg(
|
||||
(
|
||||
f"[#] [{reference}] ({self.platform}) <{buyer}>"
|
||||
f" {amount}{currency} {provider} {amount_crypto}{asset}"
|
||||
)
|
||||
)
|
||||
# Note that we have seen this reference
|
||||
self.last_dash.add(reference)
|
||||
|
||||
# Purge old trades from cache
|
||||
for ref in list(self.last_dash): # We're removing from the list on the fly
|
||||
if ref not in current_trades:
|
||||
self.last_dash.remove(ref)
|
||||
if reference and reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
self.tx.cleanup(current_trades)
|
||||
self.tx.cleanup(self.platform, current_trades)
|
||||
|
||||
@util.handle_exceptions
|
||||
def got_recent_messages(self, messages, send_irc=True):
|
||||
|
@ -192,16 +200,16 @@ class LBTC(util.Base):
|
|||
|
||||
# Send new messages on IRC
|
||||
if send_irc:
|
||||
for user, message in messages_tmp[reference]:
|
||||
for user, message in messages_tmp[reference][::-1]:
|
||||
if reference in self.last_messages:
|
||||
if not [user, message] in self.last_messages[reference]:
|
||||
self.irc.sendmsg(f"AUTO {reference}: ({user}) {message}")
|
||||
self.irc.sendmsg(f"[{reference}] ({self.platform}) <{user}> {message}")
|
||||
# Append sent messages to last_messages so we don't send them again
|
||||
self.last_messages[reference].append([user, message])
|
||||
else:
|
||||
self.last_messages[reference] = [[user, message]]
|
||||
for x in messages_tmp[reference]:
|
||||
self.irc.sendmsg(f"NEW {reference}: ({user}) {message}")
|
||||
self.irc.sendmsg(f"[{reference}] ({self.platform}) <{user}> {message}")
|
||||
|
||||
# Purge old trades from cache
|
||||
for ref in list(self.last_messages): # We're removing from the list on the fly
|
||||
|
|
Loading…
Reference in New Issue