Finish implementation and tests for the cheat system #3
114
handler/agora.py
114
handler/agora.py
|
@ -7,7 +7,7 @@ from twisted.internet.threads import deferToThread
|
||||||
from json import loads
|
from json import loads
|
||||||
from forex_python.converter import CurrencyRates
|
from forex_python.converter import CurrencyRates
|
||||||
from agoradesk_py import AgoraDesk
|
from agoradesk_py import AgoraDesk
|
||||||
from httpx import ReadTimeout
|
from httpx import ReadTimeout, ReadError
|
||||||
from pycoingecko import CoinGeckoAPI
|
from pycoingecko import CoinGeckoAPI
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -186,7 +186,10 @@ class Agora(object):
|
||||||
Get recent messages.
|
Get recent messages.
|
||||||
"""
|
"""
|
||||||
messages_tmp = {}
|
messages_tmp = {}
|
||||||
messages = self.agora.recent_messages()
|
try:
|
||||||
|
messages = self.agora.recent_messages()
|
||||||
|
except ReadError:
|
||||||
|
return False
|
||||||
if not messages["success"]:
|
if not messages["success"]:
|
||||||
return False
|
return False
|
||||||
if "data" not in messages["response"]:
|
if "data" not in messages["response"]:
|
||||||
|
@ -487,23 +490,24 @@ class Agora(object):
|
||||||
# Remove extra tabs
|
# Remove extra tabs
|
||||||
ad = ad.replace("\\t", "\t")
|
ad = ad.replace("\\t", "\t")
|
||||||
|
|
||||||
form = {"country_code": countrycode,
|
form = {
|
||||||
"currency": currency,
|
"country_code": countrycode,
|
||||||
"trade_type": "ONLINE_SELL",
|
"currency": currency,
|
||||||
"asset": asset,
|
"trade_type": "ONLINE_SELL",
|
||||||
"price_equation": price_formula,
|
"asset": asset,
|
||||||
"track_max_amount": False,
|
"price_equation": price_formula,
|
||||||
"require_trusted_by_advertiser": False,
|
"track_max_amount": False,
|
||||||
"online_provider": "REVOLUT",
|
"require_trusted_by_advertiser": False,
|
||||||
"msg": ad,
|
"online_provider": "REVOLUT",
|
||||||
"min_amount": min_amount,
|
"msg": ad,
|
||||||
"max_amount": max_amount,
|
"min_amount": min_amount,
|
||||||
"payment_method_details": settings.Agora.PaymentMethodDetails,
|
"max_amount": max_amount,
|
||||||
"account_info": paymentdetailstext,
|
"payment_method_details": settings.Agora.PaymentMethodDetails,
|
||||||
}
|
"account_info": paymentdetailstext,
|
||||||
|
}
|
||||||
|
|
||||||
# Dirty hack to test
|
# Dirty hack to test
|
||||||
#if asset == "BTC":
|
# if asset == "BTC":
|
||||||
# del form["min_amount"]
|
# del form["min_amount"]
|
||||||
ad = self.agora.ad_create(**form)
|
ad = self.agora.ad_create(**form)
|
||||||
return ad
|
return ad
|
||||||
|
@ -525,45 +529,45 @@ class Agora(object):
|
||||||
return False
|
return False
|
||||||
yield rtrn
|
yield rtrn
|
||||||
|
|
||||||
# def get_combinations(self):
|
# def get_combinations(self):
|
||||||
# """
|
# """
|
||||||
# Get all combinations of currencies and countries from the configuration.
|
# Get all combinations of currencies and countries from the configuration.
|
||||||
# :return: list of [country, currency]
|
# :return: list of [country, currency]
|
||||||
# :rtype: list
|
# :rtype: list
|
||||||
# """
|
# """
|
||||||
# currencies = loads(settings.Agora.BruteCurrencies)
|
# currencies = loads(settings.Agora.BruteCurrencies)
|
||||||
# countries = loads(settings.Agora.BruteCountries)
|
# countries = loads(settings.Agora.BruteCountries)
|
||||||
# combinations = [[country, currency] for country in countries for currency in currencies]
|
# combinations = [[country, currency] for country in countries for currency in currencies]
|
||||||
# return combinations
|
# return combinations
|
||||||
|
|
||||||
# def dist_bruteforce(self):
|
# def dist_bruteforce(self):
|
||||||
# """
|
# """
|
||||||
# Bruteforce all possible ads from the currencies and countries in the config.
|
# Bruteforce all possible ads from the currencies and countries in the config.
|
||||||
# Does not exit on errors.
|
# Does not exit on errors.
|
||||||
# :return: False or dict with response
|
# :return: False or dict with response
|
||||||
# :rtype: bool or dict
|
# :rtype: bool or dict
|
||||||
# """
|
# """
|
||||||
# combinations = self.get_combinations()
|
# combinations = self.get_combinations()
|
||||||
# for country, currency in combinations:
|
# for country, currency in combinations:
|
||||||
# rtrn = self.create_ad(country, currency)
|
# rtrn = self.create_ad(country, currency)
|
||||||
# if not rtrn:
|
# if not rtrn:
|
||||||
# yield False
|
# yield False
|
||||||
# yield rtrn
|
# yield rtrn
|
||||||
#
|
#
|
||||||
# def bruteforce_fill_blanks(self):
|
# def bruteforce_fill_blanks(self):
|
||||||
# """
|
# """
|
||||||
# Get the ads that we want to configure but have not, and fill in the blanks.
|
# Get the ads that we want to configure but have not, and fill in the blanks.
|
||||||
# :return: False or dict with response
|
# :return: False or dict with response
|
||||||
# :rtype: bool or dict
|
# :rtype: bool or dict
|
||||||
# """
|
# """
|
||||||
# existing_ads = self.enum_ads()
|
# existing_ads = self.enum_ads()
|
||||||
# combinations = self.get_combinations()
|
# combinations = self.get_combinations()
|
||||||
# for country, currency in combinations:
|
# for country, currency in combinations:
|
||||||
# if not [country, currency] in existing_ads:
|
# if not [country, currency] in existing_ads:
|
||||||
# rtrn = self.create_ad(country, currency)
|
# rtrn = self.create_ad(country, currency)
|
||||||
# if not rtrn:
|
# if not rtrn:
|
||||||
# yield False
|
# yield False
|
||||||
# yield rtrn
|
# yield rtrn
|
||||||
|
|
||||||
def strip_duplicate_ads(self):
|
def strip_duplicate_ads(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue