Properly handle ad substitutions

This commit is contained in:
Mark Veidemanis 2022-01-24 19:17:12 +00:00
parent e9ecd5fb30
commit 0cd8c0b358
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 10 additions and 4 deletions

View File

@ -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,