diff --git a/handler/agora.py b/handler/agora.py index 422ab71..050d285 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -383,24 +383,18 @@ class Agora(object): all_assets = loads(settings.Agora.AssetList) assets_not_run = set(all_assets) ^ set(self.cheat_run_on) if not assets_not_run: - print("TOP") self.cheat_run_on = [] asset = list(all_assets).pop() self.cheat_run_on.append(asset) else: - print("BOTTOM") asset = assets_not_run.pop() self.cheat_run_on.append(asset) - print("end cheat", self.cheat_run_on) if asset == "XMR": deferToThread(self.update_prices, True, False) # XMR, BTC - print("Running cheat on XMR") elif asset == "BTC": deferToThread(self.update_prices, False, True) # XMR, BTC - print("Running cheat on BTC") return asset else: - print("Running cheat normally") deferToThread(self.update_prices, xmr, btc) @handle_exceptions @@ -479,7 +473,6 @@ class Agora(object): self.log.info("Rate for {currency}: {margin}", currency=currency, margin=new_margin) else: self.log.info("Not changed rate for {currency}, keeping old margin of {margin}", currency=currency, margin=our_margin) - print("TO UPDATE", to_update) self.slow_ad_update(to_update) def slow_ad_update(self, ads): @@ -495,7 +488,6 @@ class Agora(object): while not all([x[4] for x in ads]) or iterations == 1000: for ad_index in range(len(ads)): ad_id, new_formula, asset, currency, actioned = ads[ad_index] - print("SLOW ITER", ad_id, new_formula, asset, currency, actioned) assets.add(asset) currencies.add(currency) self.log.error("ASSET {a}", a=asset) @@ -652,7 +644,7 @@ class Agora(object): return (min_local, max_local) @handle_exceptions - def create_ad(self, asset, countrycode, currency): + def create_ad(self, asset, countrycode, currency, online_provider): """ Post an ad with the given asset in a country with a given currency. Convert the min and max amounts from settings to the given currency with CurrencyRates. @@ -707,7 +699,7 @@ class Agora(object): "price_equation": price_formula, "track_max_amount": False, "require_trusted_by_advertiser": False, - "online_provider": "REVOLUT", + "online_provider": online_provider, "msg": ad, "min_amount": min_amount, "max_amount": max_amount, @@ -730,51 +722,11 @@ class Agora(object): """ for asset in loads(settings.Agora.AssetList): for currency, countrycode in loads(settings.Agora.DistList): - rtrn = self.create_ad(asset, countrycode, currency) + rtrn = self.create_ad(asset, countrycode, currency, "REVOLUT") if rtrn is False: return False yield rtrn - # def get_combinations(self): - # """ - # Get all combinations of currencies and countries from the configuration. - # :return: list of [country, currency] - # :rtype: list - # """ - # currencies = loads(settings.Agora.BruteCurrencies) - # countries = loads(settings.Agora.BruteCountries) - # combinations = [[country, currency] for country in countries for currency in currencies] - # return combinations - - # def dist_bruteforce(self): - # """ - # Bruteforce all possible ads from the currencies and countries in the config. - # Does not exit on errors. - # :return: False or dict with response - # :rtype: bool or dict - # """ - # combinations = self.get_combinations() - # for country, currency in combinations: - # rtrn = self.create_ad(country, currency) - # if not rtrn: - # yield False - # yield rtrn - # - # def bruteforce_fill_blanks(self): - # """ - # Get the ads that we want to configure but have not, and fill in the blanks. - # :return: False or dict with response - # :rtype: bool or dict - # """ - # existing_ads = self.enum_ads() - # combinations = self.get_combinations() - # for country, currency in combinations: - # if not [country, currency] in existing_ads: - # rtrn = self.create_ad(country, currency) - # if not rtrn: - # yield False - # yield rtrn - @handle_exceptions def strip_duplicate_ads(self): """ diff --git a/handler/commands.py b/handler/commands.py index fd30fbb..76a268d 100644 --- a/handler/commands.py +++ b/handler/commands.py @@ -40,7 +40,7 @@ class IRCCommands(object): if spl[1] not in loads(settings.Agora.AssetList): msg(f"Not a valid asset: {spl[1]}") return - posted = agora.create_ad(spl[1], spl[2], spl[3]) + posted = agora.create_ad(spl[1], spl[2], spl[3], "REVOLUT") if posted["success"]: msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}") else: