Add act_as_proxy config option and enable quotes on Discord

master
Nikola Forró 6 years ago
parent 84485b1cbc
commit 414d50f7ca

@ -36,6 +36,8 @@ class DiscordClient(discord.Client):
self.logger = logger
self.commands = commands
self.supported_commands = [
(re.compile(r'^!lastquote$'), self._do_lastquote),
(re.compile(r'^!findquote\s+(?P<q>")?(?P<filter>.+)(?(q)")$'), self._do_findquote),
(re.compile(r'^!(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'^!clip\s+(?P<q>")?(?P<filter>.+)(?(q)")$'), self._do_clip),
@ -64,6 +66,22 @@ class DiscordClient(discord.Client):
'Sorry {0}, you have to wait a while before running '
'the same command again'.format(message.author.mention))
async def _do_lastquote(self, server, user, message, **kwargs):
try:
result = self.commands.last_quote()
except CommandError as e:
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
else:
await self.send_message(message.channel, 'One time, Lilia said this... `#{id}: {text} [{game}] [{date}]`'.format(**result))
async def _do_findquote(self, server, user, message, filter, **kwargs):
try:
result = self.commands.find_quote(filter)
except CommandError as e:
await self.send_message(message.channel, 'Sorry {0}, {1}'.format(message.author.mention, e))
else:
await self.send_message(message.channel, 'One time, Lilia said this... `#{id}: {text} [{game}] [{date}]`'.format(**result))
@cooldown(retries=2, timeout=5*60, failure=_cooldown_failure)
async def _do_bellagram(self, server, user, message, **kwargs):
try:

@ -131,7 +131,10 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
except CommandError as e:
send_response('Sorry @{0}, {1}'.format(tags['display-name'], e))
else:
if self.config['Quotes'].getboolean('act_as_proxy'):
send_response('!quote {0}'.format(quote['id']))
else:
send_response('One time, Lilia said this... #{id}: "{text}" [{game}] [{date}]'.format(**quote))
def _do_findquote(self, tags, send_response, filter, **kwargs):
try:
@ -139,7 +142,10 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
except CommandError as e:
send_response('Sorry @{0}, {1}'.format(tags['display-name'], e))
else:
if self.config['Quotes'].getboolean('act_as_proxy'):
send_response('!quote {0}'.format(quote['id']))
else:
send_response('One time, Lilia said this... #{id}: "{text}" [{game}] [{date}]'.format(**quote))
def _do_syncquotes(self, tags, send_response, **kwargs):
master_user_id = self.config['Twitch'].getint('master_user_id')

@ -25,6 +25,7 @@ channel_ids = UC5970RJMoEcRNZl0MNp8tlQ,UCHNjavmkFUf2n0uzWSgj16w
[Quotes]
api_url = https://ladylilia.com/quotes/api
api_key = __QUOTES_API_KEY__
act_as_proxy = true
[Extra Commands]
;!command = Response Text

Loading…
Cancel
Save