From dc1b11bf1e55d46b8511099a8c04627449da71ae Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 9 Apr 2022 19:21:47 +0100 Subject: [PATCH] Fix creating ads --- handler/ux/commands.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/handler/ux/commands.py b/handler/ux/commands.py index 9de8b2a..5e0fac7 100644 --- a/handler/ux/commands.py +++ b/handler/ux/commands.py @@ -37,22 +37,31 @@ class IRCCommands(object): Post an ad on AgoraDesk with the given country and currency code. """ if length == 4: - if spl[1] not in loads(settings.Agora.AssetList): - msg(f"Not a valid asset: {spl[1]}") + asset = spl[1] + country = spl[2] + currency = spl[3] + if asset not in loads(settings.Agora.AssetList): + msg(f"Not a valid asset: {asset}") return - posted = agora.create_ad(spl[1], spl[2], spl[3], "REVOLUT") + _, account_info = tx.markets.get_valid_account_details() + posted = agora.create_ad(asset, country, currency, "NATIONAL_BANK", payment_details=account_info[currency]) if posted["success"]: msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}") else: msg(dumps(posted["response"])) elif length == 5: - if spl[1] not in loads(settings.Agora.AssetList): - msg(f"Not a valid asset: {spl[1]}") + asset = spl[1] + country = spl[2] + currency = spl[3] + provider = spl[4] + if asset not in loads(settings.Agora.AssetList): + msg(f"Not a valid asset: {asset}") return - if spl[4] not in loads(settings.Agora.ProviderList): - msg(f"Not a valid provider: {spl[4]}") + if provider not in loads(settings.Agora.ProviderList): + msg(f"Not a valid provider: {provider}") return - posted = agora.create_ad(spl[1], spl[2], spl[3], spl[4]) + _, account_info = tx.markets.get_valid_account_details() + posted = agora.create_ad(asset, country, currency, provider, payment_details=account_info[currency]) if posted["success"]: msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}") else: @@ -305,10 +314,10 @@ class IRCCommands(object): for ad in rtrn[currency]: msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}") - class apubads(object): - name = "apubads" + class lpubads(object): + name = "lpubads" authed = True - helptext = "View public adverts for LocalBitcoins. Usage: pubads []" + helptext = "View public adverts for LocalBitcoins. Usage: lpubads []" @staticmethod def run(cmd, spl, length, authed, msg, agora, tx, ux):