Make ads and pubads async
This commit is contained in:
parent
5b2e4e5bd0
commit
e105608367
|
@ -162,6 +162,14 @@ class GenericCommands(object):
|
||||||
msg(f"{message} - {message_long}")
|
msg(f"{message} - {message_long}")
|
||||||
|
|
||||||
class pubads(object):
|
class pubads(object):
|
||||||
|
@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]}")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
|
||||||
if length == 3:
|
if length == 3:
|
||||||
|
@ -170,12 +178,9 @@ class GenericCommands(object):
|
||||||
msg(f"Not a valid asset: {spl[1]}")
|
msg(f"Not a valid asset: {spl[1]}")
|
||||||
return
|
return
|
||||||
currency = spl[2]
|
currency = spl[2]
|
||||||
rtrn = caller.get_all_public_ads(assets=[asset], currencies=[currency])
|
c = caller.get_all_public_ads(assets=[asset], currencies=[currency])
|
||||||
if not rtrn:
|
c.addCallback(GenericCommands.pubads.got_pubads, currency, msg)
|
||||||
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:
|
elif length == 4:
|
||||||
asset = spl[1]
|
asset = spl[1]
|
||||||
if asset not in loads(asset_list):
|
if asset not in loads(asset_list):
|
||||||
|
@ -183,12 +188,8 @@ class GenericCommands(object):
|
||||||
return
|
return
|
||||||
providers = spl[3].split(",")
|
providers = spl[3].split(",")
|
||||||
currency = spl[2]
|
currency = spl[2]
|
||||||
rtrn = caller.get_all_public_ads(assets=[asset], currencies=[currency], providers=providers)
|
c = caller.get_all_public_ads(assets=[asset], currencies=[currency], providers=providers)
|
||||||
if not rtrn:
|
c.addCallback(GenericCommands.pubads.got_pubads, currency, msg)
|
||||||
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):
|
class cheat(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -213,11 +214,18 @@ class GenericCommands(object):
|
||||||
|
|
||||||
class ads(object):
|
class ads(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
def got_ads(ads_output, msg):
|
||||||
ads = caller.enum_ads()
|
if not ads_output:
|
||||||
for ad in ads:
|
msg("Could not get ads.")
|
||||||
|
return
|
||||||
|
for ad in ads_output:
|
||||||
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}")
|
msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
||||||
|
c = caller.enum_ads()
|
||||||
|
c.addCallback(GenericCommands.ads.got_ads, msg)
|
||||||
|
|
||||||
class withdraw(object):
|
class withdraw(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
||||||
|
|
Loading…
Reference in New Issue