|
|
@ -130,6 +130,17 @@ class Bot(discord.Client):
|
|
|
|
for tweet in tweets:
|
|
|
|
for tweet in tweets:
|
|
|
|
await channel.send(embed=self.make_twitter_embed(tweet))
|
|
|
|
await channel.send(embed=self.make_twitter_embed(tweet))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_remainder(self, seconds):
|
|
|
|
|
|
|
|
minutes = int(seconds / 60)
|
|
|
|
|
|
|
|
hours, minutes = divmod(minutes, 60)
|
|
|
|
|
|
|
|
days, hours = divmod(hours, 24)
|
|
|
|
|
|
|
|
result = ['{0} minute{1}'.format(minutes, 's' if minutes != 1 else '')]
|
|
|
|
|
|
|
|
if hours > 0:
|
|
|
|
|
|
|
|
result.append('{0} hour{1}'.format(hours, 's' if hours != 1 else ''))
|
|
|
|
|
|
|
|
if days > 0:
|
|
|
|
|
|
|
|
result.append('{0} day{1}'.format(days, 's' if days != 1 else ''))
|
|
|
|
|
|
|
|
return ', '.join(reversed(result))
|
|
|
|
|
|
|
|
|
|
|
|
async def process_youtube_event(self, data):
|
|
|
|
async def process_youtube_event(self, data):
|
|
|
|
import json; print(json.dumps(data)) # FIXME: remove
|
|
|
|
import json; print(json.dumps(data)) # FIXME: remove
|
|
|
|
entry = data.get('feed', {}).get('entry', {})
|
|
|
|
entry = data.get('feed', {}).get('entry', {})
|
|
|
@ -163,7 +174,7 @@ class Bot(discord.Client):
|
|
|
|
payload = data.copy()
|
|
|
|
payload = data.copy()
|
|
|
|
payload['feed']['entry']['reminder'] = '{0}m'.format(minutes)
|
|
|
|
payload['feed']['entry']['reminder'] = '{0}m'.format(minutes)
|
|
|
|
Timer.schedule(scheduled_start - datetime.timedelta(minutes=minutes), payload)
|
|
|
|
Timer.schedule(scheduled_start - datetime.timedelta(minutes=minutes), payload)
|
|
|
|
note = 'Live in {0} minutes!\n'.format(int(remaining / 60))
|
|
|
|
note = 'Live in {0}!\n'.format(self.format_remainder(remaining))
|
|
|
|
await channel.send('@everyone {note}**{title}**\n{link}'.format(note=note, **video))
|
|
|
|
await channel.send('@everyone {note}**{title}**\n{link}'.format(note=note, **video))
|
|
|
|
|
|
|
|
|
|
|
|
def make_youtube_embed(self, playlist):
|
|
|
|
def make_youtube_embed(self, playlist):
|
|
|
|