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.logger = logger
self.commands = commands self.commands = commands
self.supported_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'^!(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'^!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),
@ -64,6 +66,22 @@ 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_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) @cooldown(retries=2, timeout=5*60, failure=_cooldown_failure)
async def _do_bellagram(self, server, user, message, **kwargs): async def _do_bellagram(self, server, user, message, **kwargs):
try: try:

@ -131,7 +131,10 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
except CommandError as e: except CommandError as e:
send_response('Sorry @{0}, {1}'.format(tags['display-name'], e)) send_response('Sorry @{0}, {1}'.format(tags['display-name'], e))
else: else:
send_response('!quote {0}'.format(quote['id'])) 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): def _do_findquote(self, tags, send_response, filter, **kwargs):
try: try:
@ -139,7 +142,10 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
except CommandError as e: except CommandError as e:
send_response('Sorry @{0}, {1}'.format(tags['display-name'], e)) send_response('Sorry @{0}, {1}'.format(tags['display-name'], e))
else: else:
send_response('!quote {0}'.format(quote['id'])) 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): def _do_syncquotes(self, tags, send_response, **kwargs):
master_user_id = self.config['Twitch'].getint('master_user_id') master_user_id = self.config['Twitch'].getint('master_user_id')

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

Loading…
Cancel
Save