From 5bae246ad5be2a79b789c21f8a1d3e04cda77069 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 21 Oct 2003 04:44:44 +0000 Subject: [PATCH] Made names more generic. --- plugins/Google.py | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/plugins/Google.py b/plugins/Google.py index 47b1c36d5..0288a063d 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#re!/usr/bin/env python ### # Copyright (c) 2002, Jeremiah Fincher @@ -65,7 +65,7 @@ def configure(onStart, afterConnect, advanced): break if key: onStart.append('load Google') - onStart.append('googlelicensekey %s' % key) + onStart.append('google licensekey %s' % key) if 'load Alias' not in onStart: print 'Google depends on the Alias module for some commands.' if yn('Would you like to load the Alias module now?') == 'y': @@ -139,7 +139,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): else: return '%s %s' % (time, '; '.join(results)) - def googlelicensekey(self, irc, msg, args): + def licensekey(self, irc, msg, args): """ Sets the Google license key for using Google's Web Services API. This @@ -148,9 +148,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp): key = privmsgs.getArgs(args) google.setLicense(key) irc.reply(msg, conf.replySuccess) - googlelicensekey = privmsgs.checkCapability(googlelicensekey, 'admin') + licensekey = privmsgs.checkCapability(licensekey, 'admin') - def disablegooglesnarfer(self, irc, msg, args): + def disablesnarfer(self, irc, msg, args): """takes no argument Disables the snarfer that responds to all messages that begin with @@ -158,7 +158,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): """ self.snarfer = False irc.reply(msg, conf.replySuccess) - disablegooglesnarfer=privmsgs.checkCapability(disablegooglesnarfer,'admin') + disablesnarfer=privmsgs.checkCapability(disablesnarfer, 'admin') def google(self, irc, msg, args): """ [--{language,restrict}=] [--{notsafe,similar}] @@ -217,7 +217,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): categories and ' Categories include %s.' % categories) irc.reply(msg, s) - def googlefight(self, irc, msg, args): + def fight(self, irc, msg, args): """ [ ...] Returns the results of each search, in order, from greatest number @@ -233,17 +233,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): s = ', '.join(['%r: %s' % (s, i) for (i, s) in results]) irc.reply(msg, s) - def googlesite(self, irc, msg, args): - """ - - Searches Google on a specific site. - """ - (site, s) = privmsgs.getArgs(args, needed=2) - searchString = 'site:%s %s' % (site, s) - data = search(searchString, language='lang_en', safeSearch=1) - irc.reply(msg, self.formatData(data)) - - def googlespell(self, irc, msg, args): + def spell(self, irc, msg, args): """ Returns Google's spelling recommendation for . @@ -255,7 +245,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp): else: irc.reply(msg, 'No spelling suggestion made.') - def googleinfo(self, irc, msg, args): + def info(self, irc, msg, args): """takes no arguments Returns interesting information about this Google module. Mostly @@ -286,6 +276,8 @@ class Google(callbacks.PrivmsgCommandAndRegexp): _ggGroup = re.compile(r'Newsgroups: ]+>([^<]+)') def googleGroups(self, irc, msg, match): r"http://groups.google.com/[^\s]+" + if not self.snarfer: + return request = urllib2.Request(match.group(0), headers=\ {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'}) fd = urllib2.urlopen(request) @@ -312,7 +304,6 @@ class Google(callbacks.PrivmsgCommandAndRegexp): 'That doesn\'t appear to be a proper Google Groups page.')) - Class = Google