|
|
|
@ -95,16 +95,15 @@ class Agora(object):
|
|
|
|
|
reference = self.tx.tx_to_ref(contact_id)
|
|
|
|
|
buyer = contact["data"]["buyer"]["username"]
|
|
|
|
|
amount = contact["data"]["amount"]
|
|
|
|
|
if "amount_xmr" in contact["data"]:
|
|
|
|
|
asset = contact["data"]["advertisement"]["asset"]
|
|
|
|
|
if asset == "XMR":
|
|
|
|
|
amount_crypto = contact["data"]["amount_xmr"]
|
|
|
|
|
crypto = "XMR"
|
|
|
|
|
elif "amount_btc" in contact["data"]:
|
|
|
|
|
elif asset == "BTC":
|
|
|
|
|
amount_crypto = contact["data"]["amount_btc"]
|
|
|
|
|
crypto = "BTC"
|
|
|
|
|
currency = contact["data"]["currency"]
|
|
|
|
|
if not contact["data"]["is_selling"]:
|
|
|
|
|
continue
|
|
|
|
|
rtrn.append(f"{reference}: {buyer} {amount}{currency} {amount_crypto}{crypto}")
|
|
|
|
|
rtrn.append(f"{reference}: {buyer} {amount}{currency} {amount_crypto}{asset}")
|
|
|
|
|
return rtrn
|
|
|
|
|
|
|
|
|
|
def dashboard_hook(self, dash):
|
|
|
|
@ -123,22 +122,21 @@ class Agora(object):
|
|
|
|
|
current_trades.append(reference)
|
|
|
|
|
buyer = contact["data"]["buyer"]["username"]
|
|
|
|
|
amount = contact["data"]["amount"]
|
|
|
|
|
if "amount_xmr" in contact["data"]:
|
|
|
|
|
asset = contact["data"]["advertisement"]["asset"]
|
|
|
|
|
if asset == "XMR":
|
|
|
|
|
amount_crypto = contact["data"]["amount_xmr"]
|
|
|
|
|
crypto = "XMR"
|
|
|
|
|
elif "amount_btc" in contact["data"]:
|
|
|
|
|
elif asset == "BTC":
|
|
|
|
|
amount_crypto = contact["data"]["amount_btc"]
|
|
|
|
|
crypto = "BTC"
|
|
|
|
|
currency = contact["data"]["currency"]
|
|
|
|
|
if not contact["data"]["is_selling"]:
|
|
|
|
|
continue
|
|
|
|
|
if reference not in self.last_dash:
|
|
|
|
|
reference = self.tx.new_trade(contact_id, buyer, currency, amount, amount_xmr)
|
|
|
|
|
reference = self.tx.new_trade(asset, contact_id, buyer, currency, amount, amount_crypto)
|
|
|
|
|
if reference:
|
|
|
|
|
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} {amount_crypto}{crypto}")
|
|
|
|
|
self.irc.sendmsg(f"AUTO {reference}: {buyer} {amount}{currency} {amount_crypto}{asset}")
|
|
|
|
|
# Note that we have seen this reference
|
|
|
|
|
self.last_dash.add(reference)
|
|
|
|
|
|
|
|
|
@ -167,12 +165,11 @@ class Agora(object):
|
|
|
|
|
contact_id = contact["data"]["contact_id"]
|
|
|
|
|
buyer = contact["data"]["buyer"]["username"]
|
|
|
|
|
amount = contact["data"]["amount"]
|
|
|
|
|
if "amount_xmr" in contact["data"]:
|
|
|
|
|
asset = contact["data"]["advertisement"]["asset"]
|
|
|
|
|
if asset == "XMR":
|
|
|
|
|
amount_crypto = contact["data"]["amount_xmr"]
|
|
|
|
|
crypto = "XMR"
|
|
|
|
|
elif "amount_btc" in contact["data"]:
|
|
|
|
|
elif asset == "BTC":
|
|
|
|
|
amount_crypto = contact["data"]["amount_btc"]
|
|
|
|
|
crypto = "BTC"
|
|
|
|
|
currency = contact["data"]["currency"]
|
|
|
|
|
release_url = contact["actions"]["release_url"]
|
|
|
|
|
if not contact["data"]["is_selling"]:
|
|
|
|
@ -180,7 +177,7 @@ class Agora(object):
|
|
|
|
|
reference = self.tx.tx_to_ref(contact_id)
|
|
|
|
|
if not reference:
|
|
|
|
|
reference = "not_set"
|
|
|
|
|
dash_tmp.append(f"{reference}: {buyer} {amount}{currency} {amount_crypto}{crypto} {release_url}")
|
|
|
|
|
dash_tmp.append(f"{reference}: {buyer} {amount}{currency} {amount_crypto}{asset} {release_url}")
|
|
|
|
|
|
|
|
|
|
return dash_tmp
|
|
|
|
|
|
|
|
|
@ -443,10 +440,12 @@ class Agora(object):
|
|
|
|
|
max_local = max_usd * rates[currency]
|
|
|
|
|
return (min_local, max_local)
|
|
|
|
|
|
|
|
|
|
def create_ad(self, countrycode, currency):
|
|
|
|
|
def create_ad(self, asset, countrycode, currency):
|
|
|
|
|
"""
|
|
|
|
|
Post an ad in a country with a given currency.
|
|
|
|
|
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.
|
|
|
|
|
:param asset: the crypto asset to list (XMR or BTC)
|
|
|
|
|
:type asset: string
|
|
|
|
|
:param countrycode: country code
|
|
|
|
|
:param currency: currency code
|
|
|
|
|
:type countrycode: string
|
|
|
|
@ -463,6 +462,7 @@ class Agora(object):
|
|
|
|
|
else:
|
|
|
|
|
adtext = ad.replace("$PAYMENT$", settings.Agora.DefaultDetailsAd)
|
|
|
|
|
paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.DefaultDetailsPayment)
|
|
|
|
|
ad = ad.replace("$ASSET$", asset)
|
|
|
|
|
rates = self.get_rates_all()
|
|
|
|
|
if currency == "USD":
|
|
|
|
|
min_amount = float(settings.Agora.MinUSD)
|
|
|
|
@ -478,7 +478,7 @@ class Agora(object):
|
|
|
|
|
country_code=countrycode,
|
|
|
|
|
currency=currency,
|
|
|
|
|
trade_type="ONLINE_SELL",
|
|
|
|
|
asset="XMR",
|
|
|
|
|
asset=asset,
|
|
|
|
|
price_equation=price_formula,
|
|
|
|
|
track_max_amount=False,
|
|
|
|
|
require_trusted_by_advertiser=False,
|
|
|
|
@ -500,52 +500,53 @@ class Agora(object):
|
|
|
|
|
:return: False or dict with response
|
|
|
|
|
:rtype: bool or dict
|
|
|
|
|
"""
|
|
|
|
|
for currency, countrycode in loads(settings.Agora.DistList):
|
|
|
|
|
rtrn = self.create_ad(countrycode, currency)
|
|
|
|
|
if not rtrn:
|
|
|
|
|
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)
|
|
|
|
|
for asset in loads(settings.Agora.AssetList):
|
|
|
|
|
for currency, countrycode in loads(settings.Agora.DistList):
|
|
|
|
|
rtrn = self.create_ad(asset, countrycode, currency)
|
|
|
|
|
if not rtrn:
|
|
|
|
|
yield 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
|
|
|
|
|
|
|
|
|
|
def strip_duplicate_ads(self):
|
|
|
|
|
"""
|
|
|
|
|
Remove duplicate ads.
|
|
|
|
|