Removed capitalCase in method
This commit is contained in:
parent
5fdde35cbb
commit
1427bce6b3
1 changed files with 31 additions and 28 deletions
|
@ -8,7 +8,7 @@ import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
async def channelOnline(channel: str):
|
async def channel_online(channel: str):
|
||||||
url = "https://api.twitch.tv/kraken/streams/{}".format(channel)
|
url = "https://api.twitch.tv/kraken/streams/{}".format(channel)
|
||||||
with aiohttp.ClientSession() as s:
|
with aiohttp.ClientSession() as s:
|
||||||
async with s.get(url) as r:
|
async with s.get(url) as r:
|
||||||
|
@ -30,22 +30,23 @@ class Twitch:
|
||||||
while not self.bot.is_closed:
|
while not self.bot.is_closed:
|
||||||
twitch = config.getContent('twitch')
|
twitch = config.getContent('twitch')
|
||||||
for m_id, r in twitch.items():
|
for m_id, r in twitch.items():
|
||||||
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)
|
|
||||||
url = r['twitch_url']
|
url = r['twitch_url']
|
||||||
live = r['live']
|
live = r['live']
|
||||||
notify = r['notifications_on']
|
notify = r['notifications_on']
|
||||||
user = re.search("(?<=twitch.tv/)(.*)", url).group(1)
|
user = re.search("(?<=twitch.tv/)(.*)", url).group(1)
|
||||||
if not live and notify and await channelOnline(user):
|
if not live and notify and await channel_online(user):
|
||||||
|
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)
|
||||||
twitch[m_id]['live'] = 1
|
twitch[m_id]['live'] = 1
|
||||||
await self.bot.send_message(server, "{} has just gone live! "
|
fmt = "{} has just gone live! View their stream at {}".format(member.name, url)
|
||||||
"View their stream at {}".format(member.name, url))
|
await self.bot.send_message(server, fmt)
|
||||||
config.saveContent('twitch',twitch)
|
config.saveContent('twitch',twitch)
|
||||||
elif live and not await channelOnline(user):
|
elif live and not await channel_online(user):
|
||||||
|
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)
|
||||||
twitch[m_id]['live'] = 0
|
twitch[m_id]['live'] = 0
|
||||||
await self.bot.send_message(server,
|
fmt = "{} has just gone offline! Catch them next time they stream at {}".format(member.name, url)
|
||||||
"{} has just gone offline! Catch them next time they stream at {}"
|
await self.bot.send_message(server,fmt)
|
||||||
.format(member.name, url))
|
|
||||||
config.saveContent('twitch',twitch)
|
config.saveContent('twitch',twitch)
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
|
@ -53,10 +54,14 @@ class Twitch:
|
||||||
@checks.customPermsOrRole("none")
|
@checks.customPermsOrRole("none")
|
||||||
async def twitch(self, ctx, *, member: discord.Member=None):
|
async def twitch(self, ctx, *, member: discord.Member=None):
|
||||||
"""Use this command to check the twitch info of a user"""
|
"""Use this command to check the twitch info of a user"""
|
||||||
if member is not None:
|
if member is None:
|
||||||
result = config.getContent('twitch').get(ctx.message.author.id)
|
member = ctx.message.author
|
||||||
|
|
||||||
|
result = config.getContent('twitch').get(ctx.message.author.id)
|
||||||
|
if result is None:
|
||||||
|
await self.bot.say("{} has not saved their twitch URL yet!".format(member.name))
|
||||||
|
return
|
||||||
|
|
||||||
if result is not None:
|
|
||||||
url = result['twitch_url']
|
url = result['twitch_url']
|
||||||
user = re.search("(?<=twitch.tv/)(.*)", url).group(1)
|
user = re.search("(?<=twitch.tv/)(.*)", url).group(1)
|
||||||
with aiohttp.ClientSession() as s:
|
with aiohttp.ClientSession() as s:
|
||||||
|
@ -69,8 +74,6 @@ class Twitch:
|
||||||
fmt += "\nFollowers: {}".format(data['followers'])
|
fmt += "\nFollowers: {}".format(data['followers'])
|
||||||
fmt += "\nURL: {}".format(url)
|
fmt += "\nURL: {}".format(url)
|
||||||
await self.bot.say("```{}```".format(fmt))
|
await self.bot.say("```{}```".format(fmt))
|
||||||
else:
|
|
||||||
await self.bot.say("{} has not saved their twitch URL yet!".format(member.name))
|
|
||||||
|
|
||||||
@twitch.command(name='add', pass_context=True, no_pm=True)
|
@twitch.command(name='add', pass_context=True, no_pm=True)
|
||||||
@checks.customPermsOrRole("none")
|
@checks.customPermsOrRole("none")
|
||||||
|
|
Loading…
Reference in a new issue