diff --git a/plugins/Google.py b/plugins/Google.py index c9af7a857..134cdbb44 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -378,11 +378,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): r"http://groups.google.com/[^\s]+" if not self.registryValue('groupsSnarfer', msg.args[0]): return - m = match.group(0) - header = {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; ' - 'Windows NT 4.0)'} - request = webutils.Request(m, headers=header) - text = webutils.getUrl(request) + text = webutils.getUrl(match.group(0)) mThread = None mGroup = None if 'threadm=' in m: @@ -411,6 +407,24 @@ class Google(callbacks.PrivmsgCommandAndRegexp): 'Google Groups page.') googleGroups = privmsgs.urlSnarfer(googleGroups) + _calcRe = re.compile(r'(.*?)', re.I) + def calc(self, irc, msg, args): + """ + + Uses Google's calculator to calculate the value of . + """ + expr = privmsgs.getArgs(args) + expr = expr.replace('+', '%2B') + expr = expr.replace(' ', '+') + url = r'http://google.com/search?q=%s' % expr + html = webutils.getUrl(url) + match = self._calcRe.search(html) + if match is not None: + irc.reply(match.group(1)) + else: + irc.reply('Google\'s calculator didn\'t come up with anything.') + + Class = Google