Finish implementation and tests for the cheat system #3

Closed
m wants to merge 67 commits from cheat-refactor into master
1 changed files with 59 additions and 55 deletions
Showing only changes of commit 862a1fa28b - Show all commits

View File

@ -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 = {}
try:
messages = self.agora.recent_messages() 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,7 +490,8 @@ class Agora(object):
# Remove extra tabs # Remove extra tabs
ad = ad.replace("\\t", "\t") ad = ad.replace("\\t", "\t")
form = {"country_code": countrycode, form = {
"country_code": countrycode,
"currency": currency, "currency": currency,
"trade_type": "ONLINE_SELL", "trade_type": "ONLINE_SELL",
"asset": asset, "asset": asset,
@ -503,7 +507,7 @@ class Agora(object):
} }
# 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
@ -536,34 +540,34 @@ class Agora(object):
# 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):
""" """