Skip to content

Commit

Permalink
currency: add .currencies command to list supported symbols
Browse files Browse the repository at this point in the history
Sends to PM, because the list could be quite long.

Currently allows for up to 5 messages' worth of ticker symbols.
  • Loading branch information
dgw committed Mar 31, 2023
1 parent b5eba03 commit 5eeaf55
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion sopel/modules/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def update_rates(bot):
LOGGER.debug('Rate update completed')


@plugin.command('cur', 'currency', 'exchange')
@plugin.commands('cur', 'currency', 'exchange')
@plugin.example('.cur 100 usd in btc cad eur',
r'100 USD is [\d\.]+ BTC, [\d\.]+ CAD, [\d\.]+ EUR',
re=True, online=True, vcr=True)
Expand All @@ -276,3 +276,21 @@ def exchange_re(bot, trigger):
if bot.config.currency.auto_convert:
match = EXCHANGE_REGEX.match(trigger)
exchange(bot, match)


@plugin.command('currencies')
@plugin.output_prefix(PLUGIN_OUTPUT_PREFIX)
def supported_cmd(bot, trigger):
"""List which currency symbols are supported for conversion."""
if not rates:
try:
update_rates(bot)
except Exception:
bot.reply("Couldn't fetch supported currencies. Please try again later.")
return

symbols = sorted(list(rates.keys()))

bot.say(
"Supported currency symbols: " + ' '.join(symbols),
trigger.nick, max_messages=5)

0 comments on commit 5eeaf55

Please sign in to comment.