1
0
Fork 0
mirror of synced 2024-06-28 03:00:55 +12:00

Added a loop to check if someone has gone live on Picarto

This commit is contained in:
Phxntxm 2016-08-08 16:53:29 -05:00
parent 62f78b6ee0
commit c3d66e60b4

View file

@ -30,9 +30,29 @@ class Picarto:
async def check_channels(self):
await self.bot.wait_until_ready()
while not self.bot.is_closed:
#Do the things
picarto = config.getContent('picarto')
for m_id, r in picarto.items():
url = r['picarto_url']
live = r['live']
notify = r['notifications_on']
user = re.search("(?<=picarto.tv/)(.*)", url).group(1)
online = await channel_online(user)
if not live and notify and online:
server = discord.utils.find(lambda s: s.id == r['server_id'], self.bot.servers)
member = discord.utils.find(lambda m: m.id == m_id, server.members)
picarto[m_id]['live'] = 1
fmt = "{} has just gone live! View their stream at {}".format(member.name, url)
await self.bot.send_message(server, fmt)
config.saveContent('picarto', picarto)
elif live and not online:
server = discord.utils.find(lambda s: s.id == r['server_id'], self.bot.servers)
member = discord.utils.find(lambda m: m.id == m_id, server.members)
picarto[m_id]['live'] = 0
fmt = "{} has just gone offline! Catch them next time they stream at {}".format(member.name, url)
await self.bot.send_message(server, fmt)
config.saveContent('picarto', picarto)
pass
await asyncio.sleep(30)
await asyncio.sleep(30)
@commands.group(pass_context=True, invoke_without_command=True)
@checks.customPermsOrRole(send_messages=True)