Skip to content

Commit 9a286e9

Browse files
authored
Merge pull request #2439 from sopel-irc/currency-list-supported
currency: add `.currencies` command to list supported symbols
2 parents b5eba03 + 995fb11 commit 9a286e9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

sopel/modules/currency.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def update_rates(bot):
250250
LOGGER.debug('Rate update completed')
251251

252252

253-
@plugin.command('cur', 'currency', 'exchange')
253+
@plugin.commands('cur', 'currency', 'exchange')
254254
@plugin.example('.cur 100 usd in btc cad eur',
255255
r'100 USD is [\d\.]+ BTC, [\d\.]+ CAD, [\d\.]+ EUR',
256256
re=True, online=True, vcr=True)
@@ -276,3 +276,21 @@ def exchange_re(bot, trigger):
276276
if bot.config.currency.auto_convert:
277277
match = EXCHANGE_REGEX.match(trigger)
278278
exchange(bot, match)
279+
280+
281+
@plugin.command('currencies')
282+
@plugin.output_prefix(PLUGIN_OUTPUT_PREFIX)
283+
def supported_cmd(bot, trigger):
284+
"""List which currency codes are supported for conversion."""
285+
if not rates:
286+
try:
287+
update_rates(bot)
288+
except Exception:
289+
bot.reply("Couldn't fetch supported currencies. Please try again later.")
290+
return
291+
292+
codes = sorted(list(rates.keys()))
293+
294+
bot.say(
295+
"Supported currency codes: " + ' '.join(codes),
296+
trigger.nick, max_messages=5)

0 commit comments

Comments
 (0)