summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wmd/actions/google.py27
-rw-r--r--wmd/actions/modules.py2
2 files changed, 28 insertions, 1 deletions
diff --git a/wmd/actions/google.py b/wmd/actions/google.py
new file mode 100644
index 0000000..39c2269
--- /dev/null
+++ b/wmd/actions/google.py
@@ -0,0 +1,27 @@
1__author__ = 'jason@zzq.org'
2__version__ = 1.0
3
4import urllib2
5import simplejson
6
7from wmd.actions import Action
8
9import settings
10
11class GoogleSearch(Action):
12 def recv_msg(self, irc, obj_data):
13 args = obj_data.params.split(" ")
14 channel = args[0]
15 if channel == settings.NICKNAME:
16 return
17
18 if "PRIVMSG" in obj_data.command and ":!google" in args[1].lower():
19 search_string = " ".join(args[2:])
20 url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=%d&rsz=large&q=%s"%(0,search_string.replace(" ","%20"))
21 req = urllib2.Request(url)
22 opener = urllib2.build_opener()
23 data = opener.open(req).read()
24
25 data = simplejson.loads(data)
26 result = data['responseData']['results'][0]['url']
27 irc.privmsg(channel, result) \ No newline at end of file
diff --git a/wmd/actions/modules.py b/wmd/actions/modules.py
index eb726c2..e08d24c 100644
--- a/wmd/actions/modules.py
+++ b/wmd/actions/modules.py
@@ -29,7 +29,7 @@ class ReloadModule(Action):
29class LoadModule(Action): 29class LoadModule(Action):
30 def recv_msg(self, irc, obj_data): 30 def recv_msg(self, irc, obj_data):
31 username = obj_data.get_username() 31 username = obj_data.get_username()
32 32 print obj_data.__dict__
33 if username in settings.ADMINS: 33 if username in settings.ADMINS:
34 args = obj_data.params.split(" ") 34 args = obj_data.params.split(" ")
35 if "PRIVMSG" in obj_data.command and ":LOADMODULE" in args[1].upper(): 35 if "PRIVMSG" in obj_data.command and ":LOADMODULE" in args[1].upper():