diff --git a/modules/bitcoin.py b/modules/bitcoin.py index 524965c..69a397d 100644 --- a/modules/bitcoin.py +++ b/modules/bitcoin.py @@ -20,15 +20,16 @@ def bitcoin(phenny, input): "like .bitcoin 1 EUR") return - if currency == 'BTC': + if currency.upper() == 'BTC': from_btc = True currency = input.group(4) else: from_btc = False + currency = currency.upper() if not currency: currency = 'USD' - currency = currency.strip()[:3] + currency = currency.strip()[:3].upper() try: amount = decimal.Decimal(amount) diff --git a/modules/test/test_bitcoin.py b/modules/test/test_bitcoin.py index d4f7d2b..9d87b3a 100644 --- a/modules/test/test_bitcoin.py +++ b/modules/test/test_bitcoin.py @@ -83,3 +83,10 @@ class TestCalc(unittest.TestCase): out = self.phenny.say.call_args[0][0] self.assertNotRegex(out, r'[\d\.]+ BTC') + + def test_lettercase(self): + input = Mock(group=self.makegroup('1', 'btc', 'EuR')) + bitcoin(self.phenny, input) + + out = self.phenny.say.call_args[0][0] + self.assertRegex(out, r'\d+\.\d{2} EUR')