From 80613962a12ea83df42cac27f9c207b79f69cdef Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sun, 17 Nov 2013 21:36:42 -0800 Subject: [PATCH] bitcoin: support decimal input --- modules/bitcoin.py | 2 +- modules/test/test_bitcoin.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/bitcoin.py b/modules/bitcoin.py index 69a397d..6bb5720 100644 --- a/modules/bitcoin.py +++ b/modules/bitcoin.py @@ -58,4 +58,4 @@ def bitcoin(phenny, input): phenny.say("{amount} {currency}".format(amount=amount2, currency=currency2)) -bitcoin.rule = (['bitcoin'], r'(\d+)\s(\w+)(\s\w+)?') +bitcoin.rule = (['bitcoin'], r'([\d\.]+)\s(\w+)(\s\w+)?') diff --git a/modules/test/test_bitcoin.py b/modules/test/test_bitcoin.py index 9d87b3a..0342073 100644 --- a/modules/test/test_bitcoin.py +++ b/modules/test/test_bitcoin.py @@ -35,6 +35,13 @@ class TestCalc(unittest.TestCase): out = self.phenny.say.call_args[0][0] self.assertRegex(out, r'[\d\.]+ BTC') + def test_usd_decimal(self): + input = Mock(group=self.makegroup('1.25', 'USD')) + bitcoin(self.phenny, input) + + out = self.phenny.say.call_args[0][0] + self.assertRegex(out, r'[\d\.]+ BTC') + def test_eur(self): input = Mock(group=self.makegroup('1', 'EUR')) bitcoin(self.phenny, input)