Skip to content

Commit

Permalink
[currency] Make arguments case-insensitive (close sopel-irc#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw authored and fatalis committed Jan 7, 2016
1 parent 6e10c9f commit 1071e42
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sopel/modules/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,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 @@ -81,8 +82,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

0 comments on commit 1071e42

Please sign in to comment.