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}")
|
||||
|
||||
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
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux, asset_list, caller):
|
||||
if length == 3:
|
||||
|
@ -170,12 +178,9 @@ class GenericCommands(object):
|
|||
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]}")
|
||||
c = caller.get_all_public_ads(assets=[asset], currencies=[currency])
|
||||
c.addCallback(GenericCommands.pubads.got_pubads, currency, msg)
|
||||
|
||||
elif length == 4:
|
||||
asset = spl[1]
|
||||
if asset not in loads(asset_list):
|
||||
|
@ -183,12 +188,8 @@ class GenericCommands(object):
|
|||
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]}")
|
||||
c = caller.get_all_public_ads(assets=[asset], currencies=[currency], providers=providers)
|
||||
c.addCallback(GenericCommands.pubads.got_pubads, currency, msg)
|
||||
|
||||
class cheat(object):
|
||||
@staticmethod
|
||||
|
@ -213,11 +214,18 @@ class GenericCommands(object):
|
|||
|
||||
class ads(object):
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
||||
ads = caller.enum_ads()
|
||||
for ad in ads:
|
||||
def got_ads(ads_output, msg):
|
||||
if not ads_output:
|
||||
msg("Could not get ads.")
|
||||
return
|
||||
for ad in ads_output:
|
||||
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):
|
||||
@staticmethod
|
||||
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
|
||||
|
|
Loading…
Reference in New Issue