Skip to content

Commit

Permalink
Merge pull request #983 from dgw/979-currency-case
Browse files Browse the repository at this point in the history
[currency] Make arguments case-insensitive (close #979)
  • Loading branch information
embolalia committed Jan 6, 2016
2 parents c4af7e8 + 317b1d6 commit dfbd99e
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 dfbd99e

Please sign in to comment.