Skip to content

Instantly share code, notes, and snippets.

@raku-cat
Created July 4, 2017 16:37
Show Gist options
  • Save raku-cat/c0c89e078a15ca47e2b9b75a326c0281 to your computer and use it in GitHub Desktop.
Save raku-cat/c0c89e078a15ca47e2b9b75a326c0281 to your computer and use it in GitHub Desktop.
async def ad_roll():
adnum = 0
while 1:
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):
adnum = 0
else:
pass
await bot.sendMessage(-1001132937659, ad[adnum])
dt = datetime.now() + timedelta(minutes=int(interval))
adnum += 1
while datetime.now() < dt:
await asyncio.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment