Avoid doubling quotation marks in quotes

master
Nikola Forró 6 years ago
parent d66ece1241
commit fa81d9f926

@ -67,13 +67,18 @@ class DiscordClient(discord.Client):
'Sorry {0}, you have to wait a while before running '
'the same command again'.format(message.author.mention))
def _format_quote(self, quote):
if '"' not in quote['text']:
quote['text'] = '"{0}"'.format(quote['text'])
return 'One time, Lilia said this... `#{id}: {text} [{game}] [{date}]`'.format(**quote)
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))
await self.send_message(message.channel, self._format_quote(result))
async def _do_findquote(self, server, user, message, filter, **kwargs):
try:
@ -81,7 +86,7 @@ class DiscordClient(discord.Client):
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))
await self.send_message(message.channel, self._format_quote(result))
@cooldown(retries=2, timeout=5*60, failure=_cooldown_failure)
async def _do_bellagram(self, server, user, message, **kwargs):

@ -108,6 +108,11 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
if cmd == message:
send_response(resp.format(user=tags['display-name']))
def _format_quote(self, quote):
if '"' not in quote['text']:
quote['text'] = '"{0}"'.format(quote['text'])
return 'One time, Lilia said this... #{id}: {text} [{game}] [{date}]'.format(**quote)
def _add_quote(self, tags, send_response, user, id, text, game, date, **kwargs):
if text[0] == text[-1] == '"':
text = text[1:-1]
@ -142,7 +147,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
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))
send_response(self._format_quote(quote))
def _do_findquote(self, tags, send_response, filter, **kwargs):
try:
@ -153,7 +158,7 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
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))
send_response(self._format_quote(quote))
def _do_syncquotes(self, tags, send_response, **kwargs):
if not self._is_mod(tags):

Loading…
Cancel
Save