From 5ace33e8df69c06266d368d0b6ccee6e5cd60b91 Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Wed, 7 Jun 2017 13:48:41 -0400 Subject: [PATCH 1/4] Add regex to skip ads on ddg Sidenote: weather tests still fail; I'll fix that eventually --- modules/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/search.py b/modules/search.py index c424d24..43b3ad2 100644 --- a/modules/search.py +++ b/modules/search.py @@ -124,7 +124,7 @@ def bing(phenny, input): bing.commands = ['bing'] bing.example = '.bing swhack' -r_duck = re.compile(r'nofollow" class="[^"]+" href=".+?(http.*?)">') +r_duck = re.compile(r'web-result.*?nofollow.*?href=".+?(http.*?)"', re.DOTALL) def duck_search(query): query = query.replace('!', '') From e4b4b506de89205e227132add8df986d28f55380 Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Thu, 8 Jun 2017 23:21:56 -0400 Subject: [PATCH 2/4] change Midotholian to Chesterfield County b/c nominatim is broken --- modules/test/test_weather.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/test/test_weather.py b/modules/test/test_weather.py index 79dd1e9..375196a 100644 --- a/modules/test/test_weather.py +++ b/modules/test/test_weather.py @@ -28,7 +28,7 @@ class TestWeather(unittest.TestCase): ('27959', check_places("Dare County", "North Carolina")), ('48067', check_places("Royal Oak", "Michigan")), ('23606', check_places("Newport News", "Virginia")), - ('23113', check_places("Midlothian", "Virginia")), + ('23113', check_places("Chesterfield County", "Virginia")), ('27517', check_places("Chapel Hill", "North Carolina")), ('15213', check_places("Allegheny County", "Pennsylvania")), ('90210', check_places("Los Angeles County", "California")), From f49a1a6eab4de9eb3c930d726142c871177510ea Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 8 Jun 2017 21:04:27 -0700 Subject: [PATCH 3/4] Fix help text --- modules/info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/info.py b/modules/info.py index 494eeaa..ce3cab2 100644 --- a/modules/info.py +++ b/modules/info.py @@ -42,8 +42,8 @@ def help(phenny, input): "For help with a command, just use .help followed by the name of" " the command, like \".help botsnack\".") phenny.say( - "If you need additional help can check out {helpurl} or you can " - "talk to my owner, {owner}.".format( + "If you need additional help, check out {helpurl} or talk to my " + "owner, {owner}.".format( helpurl=helpurl, owner=phenny.config.owner)) help.rule = (['help', 'command'], r'(.*)') From 1cd247e3564dc34d5ebc367b0f7d3c71050b6126 Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Fri, 7 Jul 2017 04:28:10 +0000 Subject: [PATCH 4/4] .c bugfix --- modules/calc.py | 2 +- modules/test/test_calc.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/calc.py b/modules/calc.py index baa4be0..0328d2c 100644 --- a/modules/calc.py +++ b/modules/calc.py @@ -22,7 +22,7 @@ subs = [ ] r_google_calc = re.compile(r'calculator-40.gif.*? = (.*?)<') -r_google_calc_exp = re.compile(r'calculator-40.gif.*? = (.*?)(.*?)<') +r_google_calc_exp = re.compile(r'calculator-40.gif.*? = (.*?)(.*?)') def c(phenny, input): """Google calculator.""" diff --git a/modules/test/test_calc.py b/modules/test/test_calc.py index 13e4839..4a405be 100644 --- a/modules/test/test_calc.py +++ b/modules/test/test_calc.py @@ -36,3 +36,9 @@ class TestCalc(unittest.TestCase): c(self.phenny, input) self.phenny.reply.assert_called_once_with('Sorry, no result.') + + def test_c_quirk(self): + input = Mock(group=lambda x: '24/50') + c(self.phenny, input) + + self.phenny.say.assert_called_once_with('0.48')