Added a loop to check if someone has gone live on Picarto
This commit is contained in:
parent
62f78b6ee0
commit
c3d66e60b4
1 changed files with 22 additions and 2 deletions
|
@ -30,9 +30,29 @@ class Picarto:
|
||||||
async def check_channels(self):
|
async def check_channels(self):
|
||||||
await self.bot.wait_until_ready()
|
await self.bot.wait_until_ready()
|
||||||
while not self.bot.is_closed:
|
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
|
pass
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
@commands.group(pass_context=True, invoke_without_command=True)
|
@commands.group(pass_context=True, invoke_without_command=True)
|
||||||
@checks.customPermsOrRole(send_messages=True)
|
@checks.customPermsOrRole(send_messages=True)
|
||||||
|
|
Loading…
Reference in a new issue