Implement OTP and fix getting public ads
This commit is contained in:
parent
b58bb1a9cd
commit
39254ef684
|
@ -11,6 +11,7 @@ from httpx import ReadTimeout, ReadError
|
|||
from pycoingecko import CoinGeckoAPI
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
from pyotp import TOTP
|
||||
|
||||
# Project imports
|
||||
from settings import settings
|
||||
|
@ -328,18 +329,15 @@ class Agora(object):
|
|||
|
||||
@handle_exceptions
|
||||
def enum_public_ads(self, coin, currency, providers=None, page=0):
|
||||
if not providers:
|
||||
providers = ["REVOLUT"]
|
||||
# buy-monero-online, buy-bitcoin-online
|
||||
# Work around Agora weirdness calling it bitcoins
|
||||
if coin == "bitcoin":
|
||||
coin = "bitcoins"
|
||||
if not providers:
|
||||
print("NO PROVIDERS")
|
||||
ads = self.agora._api_call(api_method=f"buy-{coin}-online/{currency}/REVOLUT", query_values={"page": page})
|
||||
elif len(providers) == 1:
|
||||
print("one provider")
|
||||
ads = self.agora._api_call(api_method=f"buy-{coin}-online/{currency}/providers[0]", query_values={"page": page})
|
||||
if len(providers) == 1:
|
||||
ads = self.agora._api_call(api_method=f"buy-{coin}-online/{currency}/{providers[0]}", query_values={"page": page})
|
||||
elif len(providers) > 1:
|
||||
print("more than one provider")
|
||||
ads = self.agora._api_call(api_method=f"buy-{coin}-online/{currency}", query_values={"page": page})
|
||||
if ads is None:
|
||||
return False
|
||||
|
@ -348,17 +346,8 @@ class Agora(object):
|
|||
if "data" not in ads["response"]:
|
||||
return False
|
||||
for ad in ads["response"]["data"]["ad_list"]:
|
||||
print(ad["data"]["online_provider"])
|
||||
if not providers:
|
||||
print("not providers")
|
||||
if not ad["data"]["online_provider"] == "REVOLUT":
|
||||
print("provider is not revolut")
|
||||
continue
|
||||
else:
|
||||
print("yes providers")
|
||||
if ad["data"]["online_provider"] not in providers:
|
||||
print("provider not in asked")
|
||||
continue
|
||||
if ad["data"]["online_provider"] not in providers:
|
||||
continue
|
||||
date_last_seen = ad["data"]["profile"]["last_online"]
|
||||
# Check if this person was seen recently
|
||||
if not self.last_online_recent(date_last_seen):
|
||||
|
@ -367,7 +356,6 @@ class Agora(object):
|
|||
username = ad["data"]["profile"]["username"]
|
||||
temp_price = ad["data"]["temp_price"]
|
||||
provider = ad["data"]["online_provider"]
|
||||
print(ad_id, username, temp_price, provider)
|
||||
yield [ad_id, username, temp_price, provider]
|
||||
if "pagination" in ads["response"]:
|
||||
if "next" in ads["response"]["pagination"]:
|
||||
|
@ -881,11 +869,21 @@ class Agora(object):
|
|||
|
||||
half_rounded = round(half, 8)
|
||||
|
||||
# Read OTP secret
|
||||
with open("otp.key", "r") as f:
|
||||
otp_key = f.read()
|
||||
f.close()
|
||||
otp_key = otp_key.replace("\n", "")
|
||||
|
||||
# Get OTP code
|
||||
otp_code = TOTP(otp_key)
|
||||
|
||||
# Set up the format for calling wallet_send_xmr
|
||||
send_cast = {
|
||||
"address": None,
|
||||
"amount": half_rounded,
|
||||
"password": settings.Agora.Pass,
|
||||
"otp": otp_code.now(),
|
||||
}
|
||||
|
||||
send_cast["address"] = settings.XMR.Wallet1
|
||||
|
|
Loading…
Reference in New Issue