2022-03-04 22:47:06 +00:00
|
|
|
# Other library imports
|
|
|
|
from json import dumps, loads
|
|
|
|
|
2022-07-15 10:09:54 +00:00
|
|
|
import db
|
2023-02-09 07:20:00 +00:00
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
# Project imports
|
|
|
|
from settings import settings
|
|
|
|
|
|
|
|
|
2022-04-12 21:06:45 +00:00
|
|
|
class GenericCommands(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
class trades(object):
|
2022-05-03 07:48:58 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_trades(trades, msg):
|
|
|
|
if not trades:
|
|
|
|
msg("No open trades.")
|
|
|
|
return
|
|
|
|
for trade_id in trades:
|
|
|
|
msg(trade_id)
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
2022-04-12 21:06:45 +00:00
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
2022-03-04 22:47:06 +00:00
|
|
|
"""
|
|
|
|
Get details of open trades and post on IRC.
|
|
|
|
"""
|
2022-04-12 21:06:45 +00:00
|
|
|
|
2022-05-02 17:21:03 +00:00
|
|
|
trades = caller.get_dashboard_irc()
|
2022-05-03 07:48:58 +00:00
|
|
|
trades.addCallback(GenericCommands.trades.got_trades, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class create(object):
|
|
|
|
@staticmethod
|
2022-07-15 10:09:54 +00:00
|
|
|
def run(
|
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
asset_list,
|
|
|
|
provider_list,
|
|
|
|
caller,
|
|
|
|
):
|
2022-03-04 22:47:06 +00:00
|
|
|
"""
|
2022-04-13 17:29:44 +00:00
|
|
|
Post an ad on AgoraDesk/LBTC with the given country and currency code.
|
2022-03-04 22:47:06 +00:00
|
|
|
"""
|
|
|
|
if length == 4:
|
2022-04-09 18:21:47 +00:00
|
|
|
asset = spl[1]
|
|
|
|
country = spl[2]
|
|
|
|
currency = spl[3]
|
2022-04-13 17:29:44 +00:00
|
|
|
if asset not in loads(asset_list):
|
2022-04-09 18:21:47 +00:00
|
|
|
msg(f"Not a valid asset: {asset}")
|
2022-03-04 22:47:06 +00:00
|
|
|
return
|
2022-04-18 16:23:17 +00:00
|
|
|
_, account_info = tx.markets.get_valid_account_details(caller.platform)
|
2022-04-13 17:29:44 +00:00
|
|
|
posted = caller.create_ad(
|
2022-04-12 21:06:45 +00:00
|
|
|
asset,
|
|
|
|
country,
|
|
|
|
currency,
|
|
|
|
"NATIONAL_BANK",
|
|
|
|
payment_details=account_info[currency],
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
if posted["success"]:
|
2022-07-15 10:09:54 +00:00
|
|
|
msg(
|
|
|
|
f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}"
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
else:
|
|
|
|
msg(dumps(posted["response"]))
|
|
|
|
elif length == 5:
|
2022-04-09 18:21:47 +00:00
|
|
|
asset = spl[1]
|
|
|
|
country = spl[2]
|
|
|
|
currency = spl[3]
|
|
|
|
provider = spl[4]
|
2022-04-13 17:29:44 +00:00
|
|
|
if asset not in loads(asset_list):
|
2022-04-09 18:21:47 +00:00
|
|
|
msg(f"Not a valid asset: {asset}")
|
2022-03-04 22:47:06 +00:00
|
|
|
return
|
2022-04-13 17:29:44 +00:00
|
|
|
if provider not in loads(provider_list):
|
2022-04-09 18:21:47 +00:00
|
|
|
msg(f"Not a valid provider: {provider}")
|
2022-03-04 22:47:06 +00:00
|
|
|
return
|
2022-04-18 16:23:17 +00:00
|
|
|
_, account_info = tx.markets.get_valid_account_details(caller.platform)
|
2022-04-13 17:29:44 +00:00
|
|
|
posted = caller.create_ad(
|
2022-04-12 21:06:45 +00:00
|
|
|
asset,
|
|
|
|
country,
|
|
|
|
currency,
|
|
|
|
provider,
|
|
|
|
payment_details=account_info[currency],
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
if posted["success"]:
|
2022-07-15 10:09:54 +00:00
|
|
|
msg(
|
|
|
|
f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}"
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
else:
|
|
|
|
msg(dumps(posted["response"]))
|
|
|
|
|
|
|
|
class messages(object):
|
|
|
|
@staticmethod
|
2022-04-13 17:29:44 +00:00
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
2022-03-04 22:47:06 +00:00
|
|
|
"""
|
|
|
|
Get all messages for all open trades or a given trade.
|
|
|
|
"""
|
|
|
|
if length == 1:
|
2022-05-05 17:16:56 +00:00
|
|
|
m = caller.api.recent_messages()
|
|
|
|
m.addCallback(caller.got_recent_messages)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
elif length == 2:
|
|
|
|
tx = tx.ref_to_tx(spl[1])
|
|
|
|
if not tx:
|
|
|
|
msg(f"No such reference: {spl[1]}")
|
|
|
|
return
|
2022-04-13 17:29:44 +00:00
|
|
|
messages = caller.get_messages(spl[1], send_irc=False)
|
2022-03-04 22:47:06 +00:00
|
|
|
if not messages:
|
|
|
|
msg("No messages.")
|
|
|
|
for message in messages:
|
|
|
|
msg(f"{spl[1]}: {message}")
|
|
|
|
|
|
|
|
class dist(object):
|
|
|
|
@staticmethod
|
2022-04-13 17:29:44 +00:00
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
|
2022-03-04 22:47:06 +00:00
|
|
|
# Distribute out our ad to all countries in the config
|
|
|
|
if length == 2:
|
|
|
|
asset = spl[1]
|
2022-04-13 17:29:44 +00:00
|
|
|
if asset not in loads(asset_list):
|
2022-03-04 22:47:06 +00:00
|
|
|
msg(f"Not a valid asset: {spl[1]}")
|
|
|
|
return
|
2022-04-13 17:29:44 +00:00
|
|
|
for x in caller.dist_countries(filter_asset=asset):
|
2022-03-04 22:47:06 +00:00
|
|
|
if x["success"]:
|
2022-07-15 10:09:54 +00:00
|
|
|
msg(
|
|
|
|
f"{x['response']['data']['message']}: {x['response']['data']['ad_id']}"
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
else:
|
|
|
|
msg(dumps(x["response"]))
|
|
|
|
elif length == 1:
|
2022-04-13 17:29:44 +00:00
|
|
|
for x in caller.dist_countries():
|
2022-03-04 22:47:06 +00:00
|
|
|
if x["success"]:
|
2022-07-15 10:09:54 +00:00
|
|
|
msg(
|
|
|
|
f"{x['response']['data']['message']}: {x['response']['data']['ad_id']}"
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
else:
|
|
|
|
msg(dumps(x["response"]))
|
|
|
|
|
|
|
|
class redist(object):
|
|
|
|
@staticmethod
|
2022-05-10 20:41:16 +00:00
|
|
|
def got_redist(redist_output, msg):
|
|
|
|
for x in redist_output:
|
2022-03-04 22:47:06 +00:00
|
|
|
if x[0]["success"]:
|
|
|
|
msg(f"{x[0]['response']['data']['message']}: {x[1]}")
|
|
|
|
else:
|
2022-05-10 20:41:16 +00:00
|
|
|
msg(dumps(x))
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
|
|
|
c = caller.redist_countries()
|
|
|
|
c.addCallback(GenericCommands.redist.got_redist, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class stripdupes(object):
|
2022-04-13 17:29:44 +00:00
|
|
|
@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):
|
2022-05-13 16:11:17 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_pubads(pubads_output, currency, msg):
|
|
|
|
if not pubads_output:
|
|
|
|
msg("No results.")
|
|
|
|
return
|
|
|
|
for ad in pubads_output[currency]:
|
|
|
|
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]} {ad[6]}")
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
@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]
|
2022-05-13 16:11:17 +00:00
|
|
|
c = caller.get_all_public_ads(assets=[asset], currencies=[currency])
|
|
|
|
c.addCallback(GenericCommands.pubads.got_pubads, currency, msg)
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
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]
|
2022-07-15 10:09:54 +00:00
|
|
|
c = caller.get_all_public_ads(
|
|
|
|
assets=[asset], currencies=[currency], providers=providers
|
|
|
|
)
|
2022-05-13 16:11:17 +00:00
|
|
|
c.addCallback(GenericCommands.pubads.got_pubads, currency, msg)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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
|
2022-05-13 16:11:17 +00:00
|
|
|
def got_ads(ads_output, msg):
|
|
|
|
if not ads_output:
|
|
|
|
msg("Could not get ads.")
|
|
|
|
return
|
|
|
|
for ad in ads_output:
|
2022-04-13 17:29:44 +00:00
|
|
|
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}")
|
|
|
|
|
2022-05-13 16:11:17 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
|
|
|
c = caller.enum_ads()
|
|
|
|
c.addCallback(GenericCommands.ads.got_ads, msg)
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
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))
|
|
|
|
|
2022-04-15 13:26:30 +00:00
|
|
|
class wallet(object):
|
2022-06-13 16:11:52 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_wallet(wallet_output, msg, asset):
|
|
|
|
if not wallet_output["success"]:
|
|
|
|
msg(f"Error getting {asset} wallet details.")
|
|
|
|
return
|
|
|
|
if not wallet_output["response"]:
|
|
|
|
msg(f"Error getting {asset} wallet details.")
|
|
|
|
return
|
|
|
|
balance = wallet_output["response"]["data"]["total"]["balance"]
|
|
|
|
msg(f"{asset} wallet balance: {balance}")
|
|
|
|
|
2022-04-15 13:26:30 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, xmr, caller):
|
|
|
|
if xmr:
|
|
|
|
rtrn_xmr = caller.wallet_balance_xmr()
|
2022-06-13 16:11:52 +00:00
|
|
|
rtrn_xmr.addCallback(GenericCommands.wallet.got_wallet, msg, "XMR")
|
|
|
|
|
|
|
|
else:
|
|
|
|
rtrn_btc = caller.wallet_balance()
|
|
|
|
rtrn_btc.addCallback(GenericCommands.wallet.got_wallet, msg, "BTC")
|
2022-04-15 13:26:30 +00:00
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
class IRCCommands(object):
|
|
|
|
class atrades(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "atrades"
|
|
|
|
helptext = "Get all open trades for Agora."
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.trades.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.trades.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.messages.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.messages.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.dist.run(
|
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
settings.Agora.AssetList,
|
|
|
|
agora,
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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(
|
2022-07-15 10:09:54 +00:00
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
settings.LocalBitcoins.AssetList,
|
|
|
|
tx.lbtc,
|
2022-04-13 17:29:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.redist.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.redist.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.stripdupes.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.stripdupes.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class total(object):
|
|
|
|
name = "total"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get total account balance from Sinks and Agora."
|
|
|
|
|
|
|
|
@staticmethod
|
2022-06-13 16:11:52 +00:00
|
|
|
def got_total(total_output, msg):
|
|
|
|
if not total_output:
|
|
|
|
msg("Error getting total output")
|
|
|
|
return
|
|
|
|
totals = total_output[0]
|
|
|
|
wallets = total_output[1]
|
2022-03-04 22:47:06 +00:00
|
|
|
msg(f"Totals: SEK: {totals[0]} | USD: {totals[1]} | GBP: {totals[2]}")
|
|
|
|
msg(f"Wallets: XMR USD: {wallets[0]} | BTC USD: {wallets[1]}")
|
|
|
|
|
2022-06-13 16:11:52 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
totals_all = tx.money.get_total()
|
|
|
|
totals_all.addCallback(IRCCommands.total.got_total, msg)
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
class ping(object):
|
|
|
|
name = "ping"
|
|
|
|
authed = False
|
|
|
|
helptext = "Pong!"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg):
|
|
|
|
msg("Pong!")
|
|
|
|
|
|
|
|
class summon(object):
|
|
|
|
name = "summon"
|
|
|
|
authed = True
|
|
|
|
helptext = "Summon all operators."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
ux.notify.sendmsg("You have been summoned!")
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class amessage(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "amsg"
|
|
|
|
helptext = "Send a message on a trade. Usage: amsg <reference> <message...>"
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.message.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora.agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.message.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc.lbtc
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class refs(object):
|
|
|
|
name = "refs"
|
|
|
|
authed = True
|
|
|
|
helptext = "List all references"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-05-10 20:41:16 +00:00
|
|
|
msg(f"References: {', '.join(db.get_refs())}")
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class ref(object):
|
|
|
|
name = "ref"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get more information about a reference. Usage: ref <reference>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
2022-05-10 20:41:16 +00:00
|
|
|
ref_data = db.get_ref(spl[1])
|
2022-03-04 22:47:06 +00:00
|
|
|
if not ref_data:
|
|
|
|
msg(f"No such reference: {spl[1]}")
|
|
|
|
return
|
|
|
|
msg(f"{spl[1]}: {dumps(ref_data)}")
|
|
|
|
|
|
|
|
class delete(object):
|
|
|
|
name = "del"
|
|
|
|
authed = True
|
|
|
|
helptext = "Delete a reference. Usage: del <reference>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
2022-05-10 20:41:16 +00:00
|
|
|
ref_data = db.get_ref(spl[1])
|
2022-03-04 22:47:06 +00:00
|
|
|
if not ref_data:
|
|
|
|
msg(f"No such reference: {spl[1]}")
|
|
|
|
return
|
2022-05-10 20:41:16 +00:00
|
|
|
db.del_ref(spl[1])
|
2022-03-04 22:47:06 +00:00
|
|
|
msg(f"Deleted reference: {spl[1]}")
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class arelease(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "arelease"
|
|
|
|
helptext = "Release funds for a trade. Usage: arelease <reference>"
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.release.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.release.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-04-11 19:56:20 +00:00
|
|
|
class map(object):
|
|
|
|
name = "map"
|
|
|
|
authed = True
|
|
|
|
helptext = "Release funds for a trade. Usage: map <reference> <txid>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-04-23 10:53:30 +00:00
|
|
|
if length == 3:
|
2022-04-11 19:56:20 +00:00
|
|
|
reference = spl[1]
|
|
|
|
txid = spl[2]
|
|
|
|
is_released = tx.release_map_trade(reference, txid)
|
|
|
|
if is_released is None:
|
|
|
|
msg("Trade or TX invalid")
|
|
|
|
return
|
|
|
|
elif is_released is True:
|
2022-06-04 12:42:25 +00:00
|
|
|
msg("Trade released")
|
2022-04-11 19:56:20 +00:00
|
|
|
return
|
|
|
|
elif is_released is False:
|
2022-06-04 12:42:25 +00:00
|
|
|
msg("Could not release trade")
|
2022-04-11 19:56:20 +00:00
|
|
|
return
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class anuke(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "anuke"
|
|
|
|
helptext = "Delete all our adverts for Agora."
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.nuke.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.nuke.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-04-15 13:26:30 +00:00
|
|
|
class awallet(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-15 13:26:30 +00:00
|
|
|
name = "awallet"
|
2022-03-04 22:47:06 +00:00
|
|
|
helptext = "Get Agora wallet balances."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.wallet.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, True, agora.api
|
|
|
|
)
|
2022-04-15 13:26:30 +00:00
|
|
|
|
|
|
|
class lwallet(object):
|
|
|
|
authed = True
|
|
|
|
name = "lwallet"
|
|
|
|
helptext = "Get LBTC wallet balances."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.wallet.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, False, tx.lbtc.api
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class apubads(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "apubads"
|
|
|
|
helptext = "View public adverts for Agora. Usage: apubads <XMR/BTC> <currency> [<provider,...>]"
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.pubads.run(
|
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
settings.Agora.AssetList,
|
|
|
|
agora,
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-04-09 18:21:47 +00:00
|
|
|
class lpubads(object):
|
2022-04-13 17:29:44 +00:00
|
|
|
authed = True
|
2022-04-09 18:21:47 +00:00
|
|
|
name = "lpubads"
|
2022-04-13 17:29:44 +00:00
|
|
|
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(
|
2022-07-15 10:09:54 +00:00
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
settings.LocalBitcoins.AssetList,
|
|
|
|
tx.lbtc,
|
2022-04-13 17:29:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
class acheat(object):
|
2022-03-22 15:35:22 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "acheat"
|
|
|
|
helptext = "Cheat the markets by manipulating our prices to exploit people on Agora. Usage: acheat [<XMR/BTC>]"
|
2022-03-22 15:35:22 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.cheat.run(
|
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
settings.Agora.AssetList,
|
|
|
|
agora,
|
|
|
|
)
|
2022-03-22 15:35:22 +00:00
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class lcheat(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "lcheat"
|
|
|
|
helptext = "Cheat the markets by manipulating our prices to exploit people on LBTC. Usage: lcheat [<XMR/BTC>]"
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-04-13 17:29:44 +00:00
|
|
|
GenericCommands.cheat.run(
|
2022-07-15 10:09:54 +00:00
|
|
|
cmd,
|
|
|
|
spl,
|
|
|
|
length,
|
|
|
|
authed,
|
|
|
|
msg,
|
|
|
|
agora,
|
|
|
|
tx,
|
|
|
|
ux,
|
|
|
|
settings.LocalBitcoins.AssetList,
|
|
|
|
tx.lbtc,
|
2022-04-13 17:29:44 +00:00
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class acheatnext(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "acheatnext"
|
|
|
|
helptext = "Run the next currency for cheat on Agora."
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.cheatnext.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class lcheatnext(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "lcheatnext"
|
|
|
|
helptext = "Run the next currency for cheat on LBTC."
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.cheatnext.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
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)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
2022-03-22 15:35:22 +00:00
|
|
|
class lads(object):
|
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "lads"
|
|
|
|
helptext = "Get all our ad regions for LBTC."
|
2022-03-22 15:35:22 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.ads.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-03-22 15:35:22 +00:00
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
class xmr(object):
|
|
|
|
name = "xmr"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get current XMR price."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
xmr_prices = agora.money.cg.get_price(
|
|
|
|
ids="monero", vs_currencies=["sek", "usd", "gbp"]
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
price_sek = xmr_prices["monero"]["sek"]
|
|
|
|
price_usd = xmr_prices["monero"]["usd"]
|
|
|
|
price_gbp = xmr_prices["monero"]["gbp"]
|
|
|
|
msg(f"SEK: {price_sek} | USD: {price_usd} | GBP: {price_gbp}")
|
|
|
|
|
|
|
|
class btc(object):
|
|
|
|
name = "btc"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get current BTC price."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
xmr_prices = agora.money.cg.get_price(
|
|
|
|
ids="bitcoin", vs_currencies=["sek", "usd", "gbp"]
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
price_sek = xmr_prices["bitcoin"]["sek"]
|
|
|
|
price_usd = xmr_prices["bitcoin"]["usd"]
|
|
|
|
price_gbp = xmr_prices["bitcoin"]["gbp"]
|
|
|
|
msg(f"SEK: {price_sek} | USD: {price_usd} | GBP: {price_gbp}")
|
|
|
|
|
2022-04-13 17:29:44 +00:00
|
|
|
class awithdraw(object):
|
|
|
|
authed = True
|
|
|
|
name = "awithdraw"
|
|
|
|
helptext = "Take profit for Agora."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.withdraw.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, agora
|
|
|
|
)
|
2022-04-13 17:29:44 +00:00
|
|
|
|
|
|
|
class lwithdraw(object):
|
2022-03-04 22:47:06 +00:00
|
|
|
authed = True
|
2022-04-13 17:29:44 +00:00
|
|
|
name = "lwithdraw"
|
|
|
|
helptext = "Take profit for LBTC."
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-07-15 10:09:54 +00:00
|
|
|
GenericCommands.withdraw.run(
|
|
|
|
cmd, spl, length, authed, msg, agora, tx, ux, tx.lbtc
|
|
|
|
)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class remaining(object):
|
|
|
|
name = "r"
|
|
|
|
authed = True
|
|
|
|
helptext = "Show how much is left before we are able to withdraw funds."
|
|
|
|
|
2022-06-14 07:44:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_remaining(data_remaining, msg):
|
|
|
|
msg(f"Remaining: {data_remaining}USD")
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-05-05 17:16:56 +00:00
|
|
|
remaining = tx.money.get_remaining()
|
2022-06-14 07:44:29 +00:00
|
|
|
remaining.addCallback(IRCCommands.remaining.got_remaining, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class total_remaining(object):
|
|
|
|
name = "tr"
|
|
|
|
authed = True
|
|
|
|
helptext = "Show how much is left before we are able to withdraw funds (including open trades)."
|
|
|
|
|
2022-06-14 07:44:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_total_remaining(data_remaining, msg):
|
|
|
|
msg(f"Total remaining: {data_remaining}USD")
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-05-05 17:16:56 +00:00
|
|
|
remaining = tx.money.get_total_remaining()
|
2022-06-14 07:44:29 +00:00
|
|
|
remaining.addCallback(IRCCommands.total_remaining.got_total_remaining, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class tradetotal(object):
|
|
|
|
name = "tradetotal"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get total value of all open trades in USD."
|
|
|
|
|
2022-06-14 07:44:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_tradetotal(data_tradetotal, msg):
|
|
|
|
msg(f"Total trades: {data_tradetotal}USD")
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-05-05 17:16:56 +00:00
|
|
|
total = tx.money.get_open_trades_usd()
|
2022-06-14 07:44:29 +00:00
|
|
|
total.addCallback(IRCCommands.tradetotal.got_tradetotal, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class dollar(object):
|
|
|
|
name = "$"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get total value of everything, including open trades."
|
|
|
|
|
2022-06-14 07:44:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_dollar(data_dollar, msg):
|
|
|
|
msg(f"${data_dollar}")
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-05-05 17:16:56 +00:00
|
|
|
total = tx.money.get_total_with_trades()
|
2022-06-14 07:44:29 +00:00
|
|
|
total.addCallback(IRCCommands.dollar.got_dollar, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class profit(object):
|
|
|
|
name = "profit"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get total profit."
|
|
|
|
|
2022-06-14 07:44:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_profit(data_profit, msg):
|
|
|
|
msg(f"Profit: {data_profit}USD")
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
total = tx.money.get_profit()
|
2022-06-14 07:44:29 +00:00
|
|
|
total.addCallback(IRCCommands.profit.got_profit, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class tprofit(object):
|
|
|
|
name = "tprofit"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get total profit with open trades."
|
|
|
|
|
2022-06-14 07:44:29 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_tprofit(data_tprofit, msg):
|
|
|
|
msg(f"Total profit: {data_tprofit}USD")
|
|
|
|
|
2022-03-04 22:47:06 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
total = tx.money.get_profit(True)
|
2022-06-14 07:44:29 +00:00
|
|
|
total.addCallback(IRCCommands.tprofit.got_tprofit, msg)
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
class signin(object):
|
|
|
|
name = "signin"
|
|
|
|
authed = True
|
2022-03-06 18:51:16 +00:00
|
|
|
helptext = "Generate a TrueLayer signin URL. Usage: signin <account>"
|
2022-03-04 22:47:06 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-03-06 18:51:16 +00:00
|
|
|
if length == 2:
|
|
|
|
account = spl[1]
|
2022-04-11 19:56:20 +00:00
|
|
|
auth_url = tx.sinks.truelayer.create_auth_url(account)
|
2022-03-06 18:51:16 +00:00
|
|
|
msg(f"Auth URL for {account}: {auth_url}")
|
2022-03-05 21:52:31 +00:00
|
|
|
|
2022-03-22 21:56:35 +00:00
|
|
|
class nsignin(object):
|
|
|
|
name = "nsignin"
|
|
|
|
authed = True
|
|
|
|
helptext = "Generate a Nordigen signin URL. Usage: nsignin <country> <bank>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-04-12 21:06:45 +00:00
|
|
|
if length >= 3:
|
2022-03-22 21:56:35 +00:00
|
|
|
country = spl[1]
|
2022-04-12 21:06:45 +00:00
|
|
|
bank_name = " ".join(spl[2:])
|
2022-03-22 21:56:35 +00:00
|
|
|
auth_url = tx.sinks.nordigen.create_auth_url(country, bank_name)
|
|
|
|
if not auth_url:
|
|
|
|
msg("Could not find bank.")
|
|
|
|
return
|
|
|
|
msg(f"Auth URL for {bank_name}: {auth_url}")
|
|
|
|
|
2022-03-05 21:52:31 +00:00
|
|
|
class accounts(object):
|
|
|
|
name = "accounts"
|
|
|
|
authed = True
|
2022-03-22 21:56:35 +00:00
|
|
|
helptext = "Get a list of acccounts from TrueLayer. Usage: accounts <account>"
|
2022-03-05 21:52:31 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-03-06 18:51:16 +00:00
|
|
|
if length == 2:
|
|
|
|
account = spl[1]
|
|
|
|
accounts = tx.sinks.truelayer.get_accounts(account)
|
2022-03-07 20:10:59 +00:00
|
|
|
for account in accounts["results"]:
|
2022-07-15 10:09:54 +00:00
|
|
|
msg(
|
|
|
|
f"{account['account_id']} {account['display_name']} {account['currency']}"
|
|
|
|
)
|
2022-03-05 21:52:31 +00:00
|
|
|
|
2022-03-22 21:56:35 +00:00
|
|
|
class naccounts(object):
|
|
|
|
name = "naccounts"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get a list of acccounts from Nordigen. Usage: naccounts"
|
|
|
|
|
2022-05-02 17:21:03 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_accounts(accounts, msg):
|
|
|
|
for name, accounts in accounts.items():
|
|
|
|
for account in accounts:
|
|
|
|
msg(dumps(account))
|
|
|
|
|
2022-03-22 21:56:35 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 1:
|
|
|
|
accounts = tx.sinks.nordigen.get_all_account_info()
|
2022-05-02 17:21:03 +00:00
|
|
|
accounts.addCallback(IRCCommands.naccounts.got_accounts, msg)
|
2022-03-22 21:56:35 +00:00
|
|
|
|
2022-03-05 21:52:31 +00:00
|
|
|
class transactions(object):
|
|
|
|
name = "transactions"
|
|
|
|
authed = True
|
2022-03-25 18:04:17 +00:00
|
|
|
helptext = "Get a list of transactions from TrueLayer. Usage: transactions <account> <account_id>"
|
2022-03-05 21:52:31 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
2022-03-06 18:51:16 +00:00
|
|
|
if length == 3:
|
|
|
|
account = spl[1]
|
|
|
|
account_id = spl[2]
|
|
|
|
transactions = tx.sinks.truelayer.get_transactions(account, account_id)
|
2022-03-05 21:52:31 +00:00
|
|
|
for transaction in transactions:
|
2022-03-06 18:51:16 +00:00
|
|
|
txid = transaction["transaction_id"]
|
2022-04-11 19:56:20 +00:00
|
|
|
# ptxid = transaction["meta"]["provider_transaction_id"]
|
2022-03-06 18:51:16 +00:00
|
|
|
txtype = transaction["transaction_type"]
|
2022-03-05 21:52:31 +00:00
|
|
|
timestamp = transaction["timestamp"]
|
|
|
|
amount = transaction["amount"]
|
|
|
|
currency = transaction["currency"]
|
2022-03-06 18:51:16 +00:00
|
|
|
description = transaction["description"]
|
2022-04-11 19:56:20 +00:00
|
|
|
msg(f"{timestamp} {txid} {txtype} {amount}{currency} {description}")
|
2022-03-07 19:59:30 +00:00
|
|
|
|
2022-03-25 18:04:17 +00:00
|
|
|
class ntransactions(object):
|
|
|
|
name = "ntransactions"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get a list of transactions from Nordigen. Usage: ntransactions <account_id>"
|
|
|
|
|
2022-05-02 17:21:03 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_transactions(transactions, msg):
|
|
|
|
for transaction in transactions:
|
|
|
|
if "transaction_id" in transaction:
|
|
|
|
txid = transaction["transaction_id"]
|
|
|
|
else:
|
|
|
|
txid = "not_set"
|
|
|
|
timestamp = transaction["timestamp"]
|
|
|
|
amount = transaction["amount"]
|
|
|
|
currency = transaction["currency"]
|
|
|
|
reference = transaction["reference"]
|
|
|
|
msg(f"{timestamp} {txid} {amount}{currency} {reference}")
|
|
|
|
|
2022-03-25 18:04:17 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
account_id = spl[1]
|
|
|
|
transactions = tx.sinks.nordigen.get_transactions(account_id)
|
2022-07-15 10:09:54 +00:00
|
|
|
transactions.addCallback(
|
|
|
|
IRCCommands.ntransactions.got_transactions, msg
|
|
|
|
)
|
2022-03-25 18:04:17 +00:00
|
|
|
|
2022-04-09 19:18:23 +00:00
|
|
|
class nreqs(object):
|
|
|
|
name = "nreqs"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get a list of requisitions from Nordigen."
|
|
|
|
|
|
|
|
@staticmethod
|
2022-05-02 17:21:03 +00:00
|
|
|
def got_requisitions(reqs, msg):
|
2022-04-09 19:18:23 +00:00
|
|
|
for req in reqs:
|
|
|
|
id = req["id"]
|
|
|
|
institution_id = req["institution_id"]
|
|
|
|
redirect = req["link"]
|
|
|
|
msg(f"{id} {institution_id} {redirect}")
|
|
|
|
|
2022-05-02 17:21:03 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
reqs = tx.sinks.nordigen.get_requisitions()
|
|
|
|
reqs.addCallback(IRCCommands.nreqs.got_requisitions, msg)
|
|
|
|
|
2022-04-09 19:18:23 +00:00
|
|
|
class ndelreq(object):
|
|
|
|
name = "ndelreq"
|
|
|
|
authed = True
|
|
|
|
helptext = "Delete a requisition from Nordigen."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
requisition_id = spl[1]
|
|
|
|
rtrn = tx.sinks.nordigen.delete_requisition(requisition_id)
|
|
|
|
msg(f"{rtrn['summary']}")
|
|
|
|
|
2022-03-07 19:59:30 +00:00
|
|
|
class mapaccount(object):
|
|
|
|
name = "mapaccount"
|
|
|
|
authed = True
|
2022-03-22 21:56:35 +00:00
|
|
|
helptext = "Enable an account_id at a bank for use in TrueLayer. Usage: mapaccount <bank> <account_id>"
|
2022-03-07 19:59:30 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 3:
|
|
|
|
bank = spl[1]
|
|
|
|
account_id = spl[2]
|
|
|
|
account_name = tx.sinks.truelayer.map_account(bank, account_id)
|
|
|
|
if not account_name:
|
2022-06-04 12:42:25 +00:00
|
|
|
msg("Failed to map the account")
|
2022-03-07 19:59:30 +00:00
|
|
|
return
|
|
|
|
msg(f"Mapped account ID {account_id} at bank {bank} to {account_name}")
|
2022-03-08 20:42:47 +00:00
|
|
|
|
2022-03-22 21:56:35 +00:00
|
|
|
class nmapaccount(object):
|
|
|
|
name = "nmapaccount"
|
|
|
|
authed = True
|
2022-04-09 19:18:23 +00:00
|
|
|
helptext = "Enable an account_id at a bank for use in Nordigen. Usage: nmapaccount <account_id>"
|
2022-03-22 21:56:35 +00:00
|
|
|
|
2022-06-01 08:09:10 +00:00
|
|
|
@staticmethod
|
|
|
|
def got_map_account(account_name, account_id, msg):
|
|
|
|
if not account_name:
|
2022-06-04 12:42:25 +00:00
|
|
|
msg("Failed to map the account")
|
2022-06-01 08:09:10 +00:00
|
|
|
return
|
|
|
|
msg(f"Mapped account ID {account_id} to {account_name}")
|
|
|
|
|
2022-03-22 21:56:35 +00:00
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
account_id = spl[1]
|
2022-06-01 08:09:10 +00:00
|
|
|
c = tx.sinks.nordigen.map_account(account_id)
|
|
|
|
c.addCallback(IRCCommands.nmapaccount.got_map_account, account_id, msg)
|
2022-03-22 21:56:35 +00:00
|
|
|
|
2022-04-09 19:18:23 +00:00
|
|
|
class nunmapaccount(object):
|
|
|
|
name = "nunmapaccount"
|
|
|
|
authed = True
|
|
|
|
helptext = "Disable an account_id at a bank for use in Nordigen. Usage: nunmapaccount <account_id>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
account_id = spl[1]
|
|
|
|
tx.sinks.nordigen.unmap_account(account_id)
|
|
|
|
msg(f"Unmapped account ID {account_id}")
|
|
|
|
|
2022-03-08 20:42:47 +00:00
|
|
|
class unmapped(object):
|
|
|
|
name = "unmapped"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get unmapped accounts for a bank. Usage: unmapped <bank>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
bank = spl[1]
|
|
|
|
accounts_active = []
|
|
|
|
for bank, accounts in tx.sinks.truelayer.banks.items():
|
|
|
|
for account in accounts:
|
|
|
|
accounts_active.append(account)
|
|
|
|
accounts_all = tx.sinks.truelayer.get_accounts(bank)
|
2022-04-12 21:06:45 +00:00
|
|
|
accounts_unmapped = [
|
2022-07-15 10:09:54 +00:00
|
|
|
x["account_id"]
|
|
|
|
for x in accounts_all["results"]
|
|
|
|
if x["account_id"] not in accounts_active
|
2022-04-12 21:06:45 +00:00
|
|
|
]
|
2022-03-08 20:42:47 +00:00
|
|
|
msg(f"Unmapped accounts: {', '.join(accounts_unmapped)}")
|
|
|
|
|
|
|
|
class distdetails(object):
|
|
|
|
name = "distdetails"
|
|
|
|
authed = True
|
|
|
|
helptext = "Distribute account details among all ads."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
currencies = tx.sinks.currencies
|
|
|
|
tx.markets.distribute_account_details()
|
|
|
|
msg(f"Distributing account details for currencies: {', '.join(currencies)}")
|
2022-04-20 12:55:35 +00:00
|
|
|
|
|
|
|
class authlink(object):
|
|
|
|
name = "authlink"
|
|
|
|
authed = True
|
2022-07-15 10:09:54 +00:00
|
|
|
helptext = (
|
|
|
|
"Create a URL for identity verification. Usage: authlink <identifier>"
|
|
|
|
)
|
2022-04-20 12:55:35 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
identifier = spl[1]
|
|
|
|
auth_url = ux.verify.create_applicant_and_get_link(identifier)
|
|
|
|
msg(f"Verification URL: {auth_url}")
|
|
|
|
|
|
|
|
class checkauth(object):
|
|
|
|
name = "checkauth"
|
|
|
|
authed = True
|
2022-07-15 10:09:54 +00:00
|
|
|
helptext = (
|
|
|
|
"Check the authentication for an identifier. Usage: checkauth <identifier>"
|
|
|
|
)
|
2022-04-20 12:55:35 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 2:
|
|
|
|
identifier = spl[1]
|
|
|
|
verified = ux.verify.get_external_user_id_status(identifier)
|
|
|
|
msg(f"Verification status: {verified}")
|
2022-04-21 19:45:27 +00:00
|
|
|
|
|
|
|
class bankdetails(object):
|
|
|
|
name = "bankdetails"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get the bank details for a platform. Usage: bankdetails <platform> <currency>"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 3:
|
|
|
|
platform = spl[1]
|
|
|
|
currency = spl[2]
|
2022-07-15 10:09:54 +00:00
|
|
|
account_info = tx.markets.get_matching_account_details(
|
|
|
|
platform, currency
|
|
|
|
)
|
|
|
|
bank_details = tx.markets.format_payment_details(
|
|
|
|
currency, account_info, real=True
|
|
|
|
)
|
2022-04-21 19:49:14 +00:00
|
|
|
if not bank_details:
|
|
|
|
msg("Could not get bank details.")
|
|
|
|
return
|
2022-04-21 19:45:27 +00:00
|
|
|
msg(bank_details)
|
2022-04-23 10:53:30 +00:00
|
|
|
|
|
|
|
class id(object):
|
|
|
|
name = "id"
|
|
|
|
authed = True
|
2022-07-15 10:09:54 +00:00
|
|
|
helptext = (
|
|
|
|
"Get the identity information of a user. Usage: id <platform> <username>"
|
|
|
|
)
|
2022-04-23 10:53:30 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
if length == 3:
|
|
|
|
platform = spl[1]
|
|
|
|
username = spl[2]
|
2022-05-05 17:16:56 +00:00
|
|
|
uid = tx.ux.verify.create_uid(platform, username)
|
2022-04-23 10:53:30 +00:00
|
|
|
first, last = tx.ux.verify.get_external_user_id_details(uid)
|
|
|
|
msg(f"Name: {first} {last}")
|
2022-06-14 07:19:21 +00:00
|
|
|
|
|
|
|
class balance(object):
|
|
|
|
name = "balance"
|
|
|
|
authed = True
|
|
|
|
helptext = "Get the total balance of all fiat accounts."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def run(cmd, spl, length, authed, msg, agora, tx, ux):
|
|
|
|
total = ux.sinks.get_total_usd()
|
|
|
|
msg(f"Fiat balance (USD): {total}")
|