From 1f17183b1f17d1e7b12f3516be497cf475640712 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 12 Feb 2022 15:12:52 +0000 Subject: [PATCH] Fix pubads command after ads refactor --- handler/agora.py | 8 +++++--- handler/commands.py | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index 319e7ea..99a5ecc 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -429,7 +429,7 @@ class Agora(object): self.slow_ad_update(to_update) @handle_exceptions - def get_all_public_ads(self, assets=None): + def get_all_public_ads(self, assets=None, currencies=None, providers=None): """ Get all public ads for our listed currencies. :return: dict of public ads keyed by currency @@ -444,8 +444,10 @@ class Agora(object): if not assets: assets = self.markets.get_all_assets() # Get all currencies we have ads for, deduplicated - currencies = self.markets.get_all_currencies() - providers = self.markets.get_all_providers() + if not currencies: + currencies = self.markets.get_all_currencies() + if not providers: + providers = self.markets.get_all_providers() # We want to get the ads for each of these currencies and return the result rates = self.cg.get_price(ids=["monero", "bitcoin"], vs_currencies=currencies) diff --git a/handler/commands.py b/handler/commands.py index a30d7bd..5fbe266 100644 --- a/handler/commands.py +++ b/handler/commands.py @@ -331,9 +331,9 @@ class IRCCommands(object): msg(f"Not a valid asset: {spl[1]}") return currency = spl[2] - rtrn = agora.wrap_public_ads(asset, currency) - for ad in rtrn: - msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[4]} {ad[5]}") + rtrn = agora.get_all_public_ads([asset], [currency]) + for ad in rtrn[currency]: + msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}") elif length == 4: asset = spl[1] if asset not in loads(settings.Agora.AssetList): @@ -341,9 +341,9 @@ class IRCCommands(object): return providers = spl[3].split(",") currency = spl[2] - rtrn = agora.wrap_public_ads(asset, currency, providers) - for ad in rtrn: - msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]}") + rtrn = agora.get_all_public_ads([asset], [currency], providers) + for ad in rtrn[currency]: + msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}") class cheat(object): name = "cheat"