summaryrefslogtreecommitdiff
path: root/modules/google_search.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/google_search.py')
-rw-r--r--modules/google_search.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/modules/google_search.py b/modules/google_search.py
index 625cdf2..8af2c62 100644
--- a/modules/google_search.py
+++ b/modules/google_search.py
@@ -9,6 +9,7 @@ import urllib, urllib2, simplejson
class Module:
def __init__(self, bot):
self.irc = bot
+ self.irc.register_keyword('!g', self)
def search(self, s):
try:
@@ -24,19 +25,18 @@ class Module:
return
return (response['results'][0]['titleNoFormatting'], response['results'][0]['url'])
- def __call__(self, nick, channel, msg):
- if msg.startswith('!g'):
- target = channel if not channel == self.irc.nickname else nick.split('!')[0]
- args = msg.split()
- if len(args) == 1:
- self.irc.msg(target, 'Usage: !g search')
- return
- results = self.search(' '.join(args[1:]))
- if results:
- results = '\002%s\002 %s' % results
- self.irc.msg(target, results.encode('utf-8'))
- else:
- self.irc.msg(target, 'No results.')
+ def keyword(self, nick, channel, kw, msg):
+ target = channel if not channel == self.irc.nickname else nick.split('!')[0]
+ args = msg.split()
+ if len(args) == 0:
+ self.irc.msg(target, 'Usage: !g search')
+ return
+ results = self.search(' '.join(args))
+ if results:
+ results = '\002%s\002 %s' % results
+ self.irc.msg(target, results.encode('utf-8'))
+ else:
+ self.irc.msg(target, 'No results.')
if __name__ == '__main__':
import sys