|
|
@ -13,8 +13,8 @@ class DiscordClient(discord.Client):
|
|
|
|
self.logger = logger
|
|
|
|
self.logger = logger
|
|
|
|
self.commands = commands
|
|
|
|
self.commands = commands
|
|
|
|
self.supported_commands = [
|
|
|
|
self.supported_commands = [
|
|
|
|
(re.compile(r'^!(bella(gram|pics)|insta(gram|bella))$'), self._do_bellagram),
|
|
|
|
(re.compile(r'^(?P<prefix>!|\?)(bella(gram|pics)|insta(gram|bella))$'), self._do_bellagram),
|
|
|
|
(re.compile(r'^!yt\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_yt),
|
|
|
|
(re.compile(r'^(?P<prefix>!|\?)yt\s+(?P<q>")?(?P<query>.+)(?(q)")$'), self._do_yt),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
self.cooldowns = {p.pattern: {} for p, _ in self.supported_commands}
|
|
|
|
self.cooldowns = {p.pattern: {} for p, _ in self.supported_commands}
|
|
|
|
super(DiscordClient, self).__init__()
|
|
|
|
super(DiscordClient, self).__init__()
|
|
|
@ -48,27 +48,33 @@ class DiscordClient(discord.Client):
|
|
|
|
'Sorry {0}, you have to wait a while before running '
|
|
|
|
'Sorry {0}, you have to wait a while before running '
|
|
|
|
'the same command again'.format(message.author.mention))
|
|
|
|
'the same command again'.format(message.author.mention))
|
|
|
|
|
|
|
|
|
|
|
|
async def _do_bellagram(self, message, **kwargs):
|
|
|
|
async def _do_bellagram(self, message, prefix, **kwargs):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
bellagram = self.commands.bellagram()
|
|
|
|
bellagram = self.commands.bellagram()
|
|
|
|
except CommandError as e:
|
|
|
|
except CommandError as e:
|
|
|
|
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
|
|
|
|
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
if prefix == '!':
|
|
|
|
embed = discord.Embed(title=bellagram['title'], url=bellagram['url'], color=0x8545bc)
|
|
|
|
embed = discord.Embed(title=bellagram['title'], url=bellagram['url'], color=0x8545bc)
|
|
|
|
embed.set_image(url=bellagram['display_url'])
|
|
|
|
embed.set_image(url=bellagram['display_url'])
|
|
|
|
embed.set_author(name=bellagram['owner'], url=bellagram['owner_url'],
|
|
|
|
embed.set_author(name=bellagram['owner'], url=bellagram['owner_url'],
|
|
|
|
icon_url=bellagram['owner_pic_url'])
|
|
|
|
icon_url=bellagram['owner_pic_url'])
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|
|
|
|
|
elif prefix == '?':
|
|
|
|
|
|
|
|
await self.send_message(message.channel, bellagram['url'])
|
|
|
|
|
|
|
|
|
|
|
|
async def _do_yt(self, message, query, **kwargs):
|
|
|
|
async def _do_yt(self, message, query, prefix, **kwargs):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
result = self.commands.query_youtube(query)
|
|
|
|
result = self.commands.query_youtube(query)
|
|
|
|
except CommandError as e:
|
|
|
|
except CommandError as e:
|
|
|
|
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
|
|
|
|
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
if prefix == '!':
|
|
|
|
embed = discord.Embed(title=result['title'], url=result['url'],
|
|
|
|
embed = discord.Embed(title=result['title'], url=result['url'],
|
|
|
|
description=result['description'], color=0xff0000)
|
|
|
|
description=result['description'], color=0xff0000)
|
|
|
|
embed.set_thumbnail(url=result['thumbnail_url'])
|
|
|
|
embed.set_thumbnail(url=result['thumbnail_url'])
|
|
|
|
embed.set_author(name=result['channel_title'], url=result['channel_url'],
|
|
|
|
embed.set_author(name=result['channel_title'], url=result['channel_url'],
|
|
|
|
icon_url=result['channel_thumbnail_url'])
|
|
|
|
icon_url=result['channel_thumbnail_url'])
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|
await self.send_message(message.channel, embed=embed)
|
|
|
|
|
|
|
|
elif prefix == '?':
|
|
|
|
|
|
|
|
await self.send_message(message.channel, result['url'])
|
|
|
|