|
|
@ -63,6 +63,7 @@ class DiscordClient(discord.Client):
|
|
|
|
(re.compile(r'^!yt\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_yt),
|
|
|
|
(re.compile(r'^!yt\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_yt),
|
|
|
|
(re.compile(r'^!clip\s+(?P<q>")?(?P<filter>.+)(?(q)")$'), self._do_clip),
|
|
|
|
(re.compile(r'^!clip\s+(?P<q>")?(?P<filter>.+)(?(q)")$'), self._do_clip),
|
|
|
|
(re.compile(r'^!cheese\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_cheese),
|
|
|
|
(re.compile(r'^!cheese\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_cheese),
|
|
|
|
|
|
|
|
(re.compile(r'^!nextstream$'), self._do_nextstream),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
super(DiscordClient, self).__init__()
|
|
|
|
super(DiscordClient, self).__init__()
|
|
|
|
|
|
|
|
|
|
|
@ -245,3 +246,38 @@ class DiscordClient(discord.Client):
|
|
|
|
name, value = 'Base', point
|
|
|
|
name, value = 'Base', point
|
|
|
|
embed.add_field(name=name.strip(), value=value.strip(), inline=True)
|
|
|
|
embed.add_field(name=name.strip(), value=value.strip(), inline=True)
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _do_nextstream(self, server, user, message, **kwargs):
|
|
|
|
|
|
|
|
def format_delta(d):
|
|
|
|
|
|
|
|
if d.total_seconds() <= 0:
|
|
|
|
|
|
|
|
return 'In progress'
|
|
|
|
|
|
|
|
days = d.days
|
|
|
|
|
|
|
|
hours, rem = divmod(d.seconds, 60 * 60)
|
|
|
|
|
|
|
|
mins, secs = divmod(rem, 60)
|
|
|
|
|
|
|
|
result = ''
|
|
|
|
|
|
|
|
if days > 0:
|
|
|
|
|
|
|
|
result += '{0} day{1}'.format(days, 's' if days > 1 else '')
|
|
|
|
|
|
|
|
if hours > 0:
|
|
|
|
|
|
|
|
if result:
|
|
|
|
|
|
|
|
result += ', '
|
|
|
|
|
|
|
|
result += '{0} hour{1}'.format(hours, 's' if hours > 1 else '')
|
|
|
|
|
|
|
|
if result:
|
|
|
|
|
|
|
|
result += ', '
|
|
|
|
|
|
|
|
result += '{0} minute{1}'.format(mins, 's' if mins > 1 else '')
|
|
|
|
|
|
|
|
return 'In ' + result
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
result = self.commands.next_stream()
|
|
|
|
|
|
|
|
except CommandError as e:
|
|
|
|
|
|
|
|
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
embed = discord.Embed(title=result['title'],
|
|
|
|
|
|
|
|
url='https://www.twitch.tv/events/{0}'.format(result['id']),
|
|
|
|
|
|
|
|
description=result['description'], color=0x4b367c)
|
|
|
|
|
|
|
|
embed.set_thumbnail(url=result['cover_image_url'].format(width=128, height=72))
|
|
|
|
|
|
|
|
embed.set_image(url=result['game_box_large'])
|
|
|
|
|
|
|
|
embed.set_author(name='lilialil', url='https://twitch.tv/lilialil',
|
|
|
|
|
|
|
|
icon_url='https://static-cdn.jtvnw.net/jtv_user_pictures/lilialil-profile_image-7601a69cf14adae1-300x300.png')
|
|
|
|
|
|
|
|
time = dateutil.parser.parse(result['start'])
|
|
|
|
|
|
|
|
embed.add_field(name=format_delta(time - datetime.datetime.utcnow()),
|
|
|
|
|
|
|
|
value=time.strftime('%Y-%m-%d %I:%M %p GMT'), inline=False)
|
|
|
|
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|