From a1e48a8ff7c7d9aad58a3a82800a99c58e97d1c8 Mon Sep 17 00:00:00 2001 From: James Vega Date: Fri, 26 Mar 2004 00:28:51 +0000 Subject: [PATCH] Make sure the Wind Chill and Heat Index temps are configurable in Weather.ham --- plugins/Weather.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/Weather.py b/plugins/Weather.py index 4d3439d6e..3afc4df2d 100644 --- a/plugins/Weather.py +++ b/plugins/Weather.py @@ -131,6 +131,7 @@ class Weather(callbacks.Privmsg): _tempregex = re.compile( r'' r'(-?\d+)(.*?)(F|C)', re.I) + _temp = re.compile(r'(-?\d+)(.*?)(F|C)') _chillregex = re.compile( r'Wind Chill:\s+' r'([^N][^<]+)', @@ -232,16 +233,23 @@ class Weather(callbacks.Privmsg): index = '' chill = self._chillregex.search(html) if chill is not None: - #self.log.warning(chill.groups()) chill = chill.group(1) chill = utils.htmlToText(chill) - if int(chill[:-2]) < int(temp[:-2]): + tempsplit = self._temp.search(chill) + if tempsplit: + (chill, deg, unit) = tempsplit.groups() + chill = self._getTemp(int(chill), deg, unit,msg.args[0]) + if float(chill[:-2]) < float(temp[:-2]): index = ' (Wind Chill: %s)' % chill heat = self._heatregex.search(html) if heat is not None: heat = heat.group(1) heat = utils.htmlToText(heat) - if int(heat[:-2]) > int(temp[:-2]): + tempsplit = self._temp.search(heat) + if tempsplit: + (heat, deg, unit) = tempsplit.groups() + heat = self._getTemp(int(heat), deg, unit,msg.args[0]) + if float(heat[:-2]) > float(temp[:-2]): index = ' (Heat Index: %s)' % heat if temp and conds and city and state: conds = conds.replace('Tsra', 'Thunderstorms')