PageRenderTime 96ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/xchat/lddg.py

http://stuffpack.googlecode.com/
Python | 23 lines | 16 code | 5 blank | 2 comment | 1 complexity | c2e7af7088b161dc06386a7e9d72b110 MD5 | raw file
  1. #!/usr/bin/env python
  2. __module_name__ = "let me DDG that for you (/ddg)"
  3. __module_version__ = "0.9"
  4. __module_description__ = "Operates duck duck go for you"
  5. import xchat
  6. import urllib
  7. print "\0034",__module_name__, __module_version__,"loading...\003"
  8. def letmeduckit(word, word_eol, userdata):
  9. if len(word) < 2:
  10. print ("Choose something to ddg for");
  11. return;
  12. wordStr = "+".join(word[1:])
  13. print "DuckDuckGoing for "+wordStr
  14. endUrl = urllib.urlopen('http://tinyurl.com/api-create.php?url=http://lmddgtfy.com/?q='+wordStr).read()
  15. print endUrl
  16. xchat.command("PRIVMSG " + xchat.get_info("channel") + " " + endUrl)
  17. xchat.hook_command('ddg', letmeduckit, help="pick your search terms and type /ddg terms")
  18. #I could probably generalize this to make it for /any/ letme*it website ....