Implement LBTC versions of each command

master
Mark Veidemanis 2 years ago
parent 1c702cd755
commit e751fcd39d
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -7,11 +7,6 @@ from settings import settings
class GenericCommands(object):
class trades(object):
authed = True
platform = None
name = None
helptext = None
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
"""
@ -26,45 +21,21 @@ class GenericCommands(object):
for trade_id in trades:
msg(trade_id)
class IRCCommands(object):
class atrades(object):
authed = True
name = "atrades"
helptext = "Get all open trades for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.trades.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class ltrades(GenericCommands.trades):
authed = True
name = "ltrades"
helptext = "Get all open trades for LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.trades.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class create(object):
name = "create"
authed = True
helptext = "Create an ad. Usage: create <XMR/BTC> <country> <currency> [<provider>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, provider_list, caller):
"""
Post an ad on AgoraDesk with the given country and currency code.
Post an ad on AgoraDesk/LBTC with the given country and currency code.
"""
if length == 4:
asset = spl[1]
country = spl[2]
currency = spl[3]
if asset not in loads(settings.Agora.AssetList):
if asset not in loads(asset_list):
msg(f"Not a valid asset: {asset}")
return
_, account_info = tx.markets.get_valid_account_details()
posted = agora.create_ad(
posted = caller.create_ad(
asset,
country,
currency,
@ -80,14 +51,14 @@ class IRCCommands(object):
country = spl[2]
currency = spl[3]
provider = spl[4]
if asset not in loads(settings.Agora.AssetList):
if asset not in loads(asset_list):
msg(f"Not a valid asset: {asset}")
return
if provider not in loads(settings.Agora.ProviderList):
if provider not in loads(provider_list):
msg(f"Not a valid provider: {provider}")
return
_, account_info = tx.markets.get_valid_account_details()
posted = agora.create_ad(
posted = caller.create_ad(
asset,
country,
currency,
@ -100,17 +71,13 @@ class IRCCommands(object):
msg(dumps(posted["response"]))
class messages(object):
name = "messages"
authed = True
helptext = "Get messages. Usage: messages [<reference>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
"""
Get all messages for all open trades or a given trade.
"""
if length == 1:
messages = agora.get_recent_messages()
messages = caller.get_recent_messages()
if messages is False:
msg("Error getting messages.")
return
@ -127,59 +94,276 @@ class IRCCommands(object):
if not tx:
msg(f"No such reference: {spl[1]}")
return
messages = agora.get_messages(spl[1], send_irc=False)
messages = caller.get_messages(spl[1], send_irc=False)
if not messages:
msg("No messages.")
for message in messages:
msg(f"{spl[1]}: {message}")
class dist(object):
name = "dist"
authed = True
helptext = "Distribute all our chosen currency and country ad pairs. Usage: dist [<XMR/BTC>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
# Distribute out our ad to all countries in the config
if length == 2:
asset = spl[1]
if asset not in loads(settings.Agora.AssetList):
if asset not in loads(asset_list):
msg(f"Not a valid asset: {spl[1]}")
return
for x in agora.dist_countries(filter_asset=asset):
for x in caller.dist_countries(filter_asset=asset):
if x["success"]:
msg(f"{x['response']['data']['message']}: {x['response']['data']['ad_id']}")
else:
msg(dumps(x["response"]))
elif length == 1:
for x in agora.dist_countries():
for x in caller.dist_countries():
if x["success"]:
msg(f"{x['response']['data']['message']}: {x['response']['data']['ad_id']}")
else:
msg(dumps(x["response"]))
class redist(object):
name = "redist"
authed = True
helptext = "Update all ads with details."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
for x in agora.redist_countries():
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
for x in caller.redist_countries():
if x[0]["success"]:
msg(f"{x[0]['response']['data']['message']}: {x[1]}")
else:
msg(dumps(x[0]["response"]))
class stripdupes(object):
name = "stripdupes"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
rtrn = caller.strip_duplicate_ads()
msg(dumps(rtrn))
class message(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
if length > 2:
full_msg = " ".join(spl[2:])
reference = tx.ref_to_tx(spl[1])
if not reference:
msg(f"No such reference: {spl[1]}")
return
rtrn = caller.contact_message_post(reference, full_msg)
msg(f"Sent {full_msg} to {reference}: {rtrn}")
class release(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
if length == 2:
tx = tx.ref_to_tx(spl[1])
if not tx:
msg(f"No such reference: {spl[1]}")
return
rtrn = caller.release_funds(tx)
message = rtrn["message"]
message_long = rtrn["response"]["data"]["message"]
msg(f"{message} - {message_long}")
class pubads(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
if length == 3:
asset = spl[1]
if asset not in loads(asset_list):
msg(f"Not a valid asset: {spl[1]}")
return
currency = spl[2]
rtrn = caller.get_all_public_ads(assets=[asset], currencies=[currency])
if not rtrn:
msg("No results.")
return
for ad in rtrn[currency]:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
elif length == 4:
asset = spl[1]
if asset not in loads(asset_list):
msg(f"Not a valid asset: {spl[1]}")
return
providers = spl[3].split(",")
currency = spl[2]
rtrn = caller.get_all_public_ads(assets=[asset], currencies=[currency], providers=providers)
if not rtrn:
msg("No results.")
return
for ad in rtrn[currency]:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
class cheat(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
if length == 1:
caller.run_cheat_in_thread()
msg("Running cheat in thread.")
elif length == 2:
asset = spl[1]
if asset not in loads(asset_list):
msg(f"Not a valid asset: {spl[1]}")
return
caller.run_cheat_in_thread([asset])
msg(f"Running cheat in thread for {asset}.")
class cheatnext(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
if length == 1:
asset = caller.run_cheat_in_thread()
msg(f"Running next asset for cheat in thread: {asset}")
class ads(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
ads = caller.enum_ads()
for ad in ads:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}")
class withdraw(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
caller.withdraw_funds()
class nuke(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
rtrn = caller.nuke_ads()
msg(dumps(rtrn))
class IRCCommands(object):
class atrades(object):
authed = True
helptext = "Remove all duplicate adverts."
name = "atrades"
helptext = "Get all open trades for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
rtrn = agora.strip_duplicate_ads()
msg(dumps(rtrn))
GenericCommands.trades.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class ltrades(object):
authed = True
name = "ltrades"
helptext = "Get all open trades for LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.trades.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class acreate(object):
name = "acreate"
authed = True
helptext = "Create an ad on Agora. Usage: acreate <XMR/BTC> <country> <currency> [<provider>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.create.run(
cmd,
spl,
length,
authed,
msg,
agora,
tx,
ux,
settings.Agora.AssetList,
settings.Agora.ProviderList,
agora,
)
class lcreate(object):
name = "lcreate"
authed = True
helptext = "Create an ad on LBTC. Usage: lcreate <XMR/BTC> <country> <currency> [<provider>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.create.run(
cmd,
spl,
length,
authed,
msg,
agora,
tx,
ux,
settings.LocalBitcoins.AssetList,
settings.LocalBitcoins.ProviderList,
tx.lbtc,
)
class amessages(object):
authed = True
name = "amessages"
helptext = "Get messages for Agora. Usage: amessages [<reference>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.messages.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lmessages(object):
authed = True
name = "lmessages"
helptext = "Get messages for LBTC. Usage: lmessages [<reference>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.messages.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class adist(object):
authed = True
name = "adist"
helptext = "Distribute all our chosen currency and country ad pairs for Agora. Usage: adist [<XMR/BTC>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.dist.run(cmd, spl, length, authed, msg, agora, tx, ux, settings.Agora.AssetList, agora)
class ldist(object):
authed = True
name = "ldist"
helptext = "Distribute all our chosen currency and country ad pairs for LBTC. Usage: ldist [<XMR/BTC>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.dist.run(
cmd, spl, length, authed, msg, agora, tx, ux, settings.LocalBitcoins.AssetList, tx.lbtc
)
class aredist(object):
authed = True
name = "aredist"
helptext = "Update all ads with details for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.redist.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lredist(object):
authed = True
name = "lredist"
helptext = "Update all ads with details for LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.redist.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class astripdupes(object):
authed = True
name = "astripdupes"
helptext = "Remove all duplicate adverts for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.stripdupes.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lstripdupes(object):
authed = True
name = "lstripdupes"
helptext = "Remove all duplicate adverts for LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.stripdupes.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class total(object):
name = "total"
@ -212,21 +396,23 @@ class IRCCommands(object):
def run(cmd, spl, length, authed, msg, agora, tx, ux):
ux.notify.sendmsg("You have been summoned!")
class message(object):
name = "msg"
class amessage(object):
authed = True
helptext = "Send a message on a trade. Usage: msg <reference> <message...>"
name = "amsg"
helptext = "Send a message on a trade. Usage: amsg <reference> <message...>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length > 2:
full_msg = " ".join(spl[2:])
reference = tx.ref_to_tx(spl[1])
if not reference:
msg(f"No such reference: {spl[1]}")
return
rtrn = agora.agora.contact_message_post(reference, full_msg)
msg(f"Sent {full_msg} to {reference}: {rtrn}")
GenericCommands.message.run(cmd, spl, length, authed, msg, agora, tx, ux, agora.agora)
class lmessage(object):
authed = True
name = "lmsg"
helptext = "Send a message on a trade. Usage: lmsg <reference> <message...>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.message.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc.lbtc)
class refs(object):
name = "refs"
@ -266,22 +452,23 @@ class IRCCommands(object):
tx.del_ref(spl[1])
msg(f"Deleted reference: {spl[1]}")
class release(object):
name = "release"
class arelease(object):
authed = True
helptext = "Release funds for a trade. Usage: release <reference>"
name = "arelease"
helptext = "Release funds for a trade. Usage: arelease <reference>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 2:
tx = tx.ref_to_tx(spl[1])
if not tx:
msg(f"No such reference: {spl[1]}")
return
rtrn = agora.release_funds(tx)
message = rtrn["message"]
message_long = rtrn["response"]["data"]["message"]
msg(f"{message} - {message_long}")
GenericCommands.release.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lrelease(object):
authed = True
name = "lrelease"
helptext = "Release funds for a trade. Usage: lrelease <reference>"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.release.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class map(object):
name = "map"
@ -304,15 +491,23 @@ class IRCCommands(object):
msg(f"Could not release trade")
return
class nuke(object):
name = "nuke"
class anuke(object):
authed = True
helptext = "Delete all our adverts."
name = "anuke"
helptext = "Delete all our adverts for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
rtrn = agora.nuke_ads()
msg(dumps(rtrn))
GenericCommands.nuke.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lnuke(object):
authed = True
name = "lnuke"
helptext = "Delete all our adverts for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.nuke.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class wallet(object):
name = "wallet"
@ -334,122 +529,81 @@ class IRCCommands(object):
msg(f"XMR wallet balance: {balance_xmr}")
msg(f"BTC wallet balance: {balance_btc}")
class pubads(object):
name = "pubads"
class apubads(object):
authed = True
helptext = "View public adverts for Agora. Usage: pubads <XMR/BTC> <currency> [<provider,...>]"
name = "apubads"
helptext = "View public adverts for Agora. Usage: apubads <XMR/BTC> <currency> [<provider,...>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 3:
asset = spl[1]
if asset not in loads(settings.Agora.AssetList):
msg(f"Not a valid asset: {spl[1]}")
return
currency = spl[2]
rtrn = agora.get_all_public_ads(assets=[asset], currencies=[currency])
if not rtrn:
msg("No results.")
return
for ad in rtrn[currency]:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
elif length == 4:
asset = spl[1]
if asset not in loads(settings.Agora.AssetList):
msg(f"Not a valid asset: {spl[1]}")
return
providers = spl[3].split(",")
currency = spl[2]
rtrn = agora.get_all_public_ads(assets=[asset], currencies=[currency], providers=providers)
if not rtrn:
msg("No results.")
return
for ad in rtrn[currency]:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
GenericCommands.pubads.run(cmd, spl, length, authed, msg, agora, tx, ux, settings.Agora.AssetList, agora)
class lpubads(object):
authed = True
name = "lpubads"
helptext = "View public adverts for LBTC. Usage: lpubads <XMR/BTC> <currency> [<provider,...>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.pubads.run(
cmd, spl, length, authed, msg, agora, tx, ux, settings.LocalBitcoins.AssetList, tx.lbtc
)
class acheat(object):
authed = True
helptext = "View public adverts for LocalBitcoins. Usage: lpubads <XMR/BTC> <currency> [<provider,...>]"
name = "acheat"
helptext = "Cheat the markets by manipulating our prices to exploit people on Agora. Usage: acheat [<XMR/BTC>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 3:
asset = spl[1]
if asset not in loads(settings.LocalBitcoins.AssetList):
msg(f"Not a valid asset: {spl[1]}")
return
currency = spl[2]
rtrn = tx.lbtc.get_all_public_ads(assets=[asset], currencies=[currency])
if not rtrn:
msg("No results.")
return
for ad in rtrn[currency]:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
elif length == 4:
asset = spl[1]
if asset not in loads(settings.LocalBitcoins.AssetList):
msg(f"Not a valid asset: {spl[1]}")
return
providers = spl[3].split(",")
currency = spl[2]
rtrn = tx.lbtc.get_all_public_ads(assets=[asset], currencies=[currency], providers=providers)
if not rtrn:
msg("No results.")
return
for ad in rtrn[currency]:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
GenericCommands.cheat.run(cmd, spl, length, authed, msg, agora, tx, ux, settings.Agora.AssetList, agora)
class cheat(object):
name = "cheat"
class lcheat(object):
authed = True
helptext = "Cheat the markets by manipulating our prices to exploit people. Usage: cheat [<XMR/BTC>]"
name = "lcheat"
helptext = "Cheat the markets by manipulating our prices to exploit people on LBTC. Usage: lcheat [<XMR/BTC>]"
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 1:
agora.run_cheat_in_thread()
msg("Running cheat in thread.")
elif length == 2:
asset = spl[1]
if asset not in loads(settings.Agora.AssetList):
msg(f"Not a valid asset: {spl[1]}")
return
agora.run_cheat_in_thread([asset])
msg(f"Running cheat in thread for {asset}.")
GenericCommands.cheat.run(
cmd, spl, length, authed, msg, agora, tx, ux, settings.LocalBitcoins.AssetList, tx.lbtc
)
class cheatnext(object):
name = "cheatnext"
class acheatnext(object):
authed = True
helptext = "Run the next currency for cheat."
name = "acheatnext"
helptext = "Run the next currency for cheat on Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 1:
asset = agora.run_cheat_in_thread()
msg(f"Running next asset for cheat in thread: {asset}")
GenericCommands.cheatnext.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class ads(object):
name = "ads"
class lcheatnext(object):
authed = True
helptext = "Get all our ad regions for Agora"
name = "lcheatnext"
helptext = "Run the next currency for cheat on LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
ads = agora.enum_ads()
for ad in ads:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}")
GenericCommands.cheatnext.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class aads(object):
authed = True
name = "aads"
helptext = "Get all our ad regions for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.ads.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lads(object):
name = "lads"
authed = True
helptext = "Get all our ad regions for LocalBitcoins"
name = "lads"
helptext = "Get all our ad regions for LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
ads = tx.sources.lbtc.enum_ads()
for ad in ads:
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}")
GenericCommands.ads.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class xmr(object):
name = "xmr"
@ -477,14 +631,23 @@ class IRCCommands(object):
price_gbp = xmr_prices["bitcoin"]["gbp"]
msg(f"SEK: {price_sek} | USD: {price_usd} | GBP: {price_gbp}")
class withdraw(object):
name = "withdraw"
class awithdraw(object):
authed = True
name = "awithdraw"
helptext = "Take profit for Agora."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
GenericCommands.withdraw.run(cmd, spl, length, authed, msg, agora, tx, ux, agora)
class lwithdraw(object):
authed = True
helptext = "Take profit."
name = "lwithdraw"
helptext = "Take profit for LBTC."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
agora.withdraw_funds()
GenericCommands.withdraw.run(cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc)
class remaining(object):
name = "r"

Loading…
Cancel
Save