From 0cd8c0b3586fc692882e8e1948978255d5497cfd Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 24 Jan 2022 19:17:12 +0000 Subject: [PATCH] Properly handle ad substitutions --- handler/agora.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index 38f2728..3420303 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -455,14 +455,19 @@ class Agora(object): """ ad = settings.Agora.Ad paymentdetails = settings.Agora.PaymentDetails + + # Substitute the currency ad = ad.replace("$CURRENCY$", currency) if countrycode == "GB" and currency == "GBP": - adtext = ad.replace("$PAYMENT$", settings.Agora.GBPDetailsAd) + ad = ad.replace("$PAYMENT$", settings.Agora.GBPDetailsAd) paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.GBPDetailsPayment) else: - adtext = ad.replace("$PAYMENT$", settings.Agora.DefaultDetailsAd) + ad = ad.replace("$PAYMENT$", settings.Agora.DefaultDetailsAd) paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.DefaultDetailsPayment) + + # Substitute the asset ad = ad.replace("$ASSET$", asset) + rates = self.get_rates_all() if asset == "XMR": min_usd = float(settings.Agora.MinUSDXMR) @@ -478,7 +483,8 @@ class Agora(object): max_amount = rates[currency] * max_usd price_formula = f"coingecko{asset.lower()}usd*usd{currency.lower()}*{settings.Agora.Margin}" # price_formula = f"coingeckoxmrusd*{settings.Agora.Margin}" - ad = settings.Agora.Ad + + # Remove extra tabs ad = ad.replace("\\t", "\t") form = {"country_code": countrycode, @@ -489,7 +495,7 @@ class Agora(object): "track_max_amount": False, "require_trusted_by_advertiser": False, "online_provider": "REVOLUT", - "msg": adtext, + "msg": ad, "min_amount": min_amount, "max_amount": max_amount, "payment_method_details": settings.Agora.PaymentMethodDetails,