Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

currency: add .currencies command to list supported symbols #2439

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 codes 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

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

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