Skip to content

Instantly share code, notes, and snippets.

@raku-cat
Created July 5, 2017 06:18
Show Gist options
  • Save raku-cat/ba2d271cee2a64012d145f71d184d56f to your computer and use it in GitHub Desktop.
Save raku-cat/ba2d271cee2a64012d145f71d184d56f to your computer and use it in GitHub Desktop.
async def ad_roll():
async def ad_roll_loop(adnum):
async with aiofiles.open('keys.json', 'r') as k:
interval = json.loads(await k.read())['interval']
async with aiofiles.open('ads.json', 'r') as a:
ad = json.loads(await a.read())['ads']
if adnum > len(ad):
await ad_roll_loop(0)
await bot.sendMessage(-1001132937659, ad[adnum])
dt = datetime.now() + timedelta(minutes=int(interval))
await ad_roll_loop(adnum + 1)
while datetime.now() < dt:
await asyncio.sleep(1)
#await ad_roll_loop(adnum + 1)
await ad_roll_loop(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment