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] Make arguments case-insensitive (close #979) #983

Merged
merged 1 commit into from
Jan 6, 2016
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
9 changes: 5 additions & 4 deletions sopel/modules/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@


def get_rate(code):
if code.upper() == 'CAD':
code = code.upper()
if code == 'CAD':
return 1, 'Canadian Dollar'
elif code.upper() == 'BTC':
elif code == 'BTC':
rates = json.loads(web.get('https://api.bitcoinaverage.com/ticker/all'))
return 1 / rates['CAD']['24h_avg'], 'Bitcoin—24hr average'

Expand Down Expand Up @@ -85,8 +86,8 @@ def display(bot, amount, of, to):
return NOLIMIT

result = amount / of_rate * to_rate
bot.say("{} {} ({}) = {} {} ({})".format(amount, of, of_name,
result, to, to_name))
bot.say("{} {} ({}) = {} {} ({})".format(amount, of.upper(), of_name,
result, to.upper(), to_name))


@commands('btc', 'bitcoin')
Expand Down