From cbdf9ebd7312bf570a212057ad793ae520bac38f Mon Sep 17 00:00:00 2001 From: "Sean B. Palmer" Date: Sat, 23 Feb 2008 12:17:06 +0000 Subject: And some new modules too... --- opt/swhack.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 opt/swhack.py (limited to 'opt/swhack.py') diff --git a/opt/swhack.py b/opt/swhack.py new file mode 100644 index 0000000..60914c0 --- /dev/null +++ b/opt/swhack.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +""" +swhack.py - Phenny Swhack Module +Copyright 2008, Sean B. Palmer, inamidst.com +Licensed under the Eiffel Forum License 2. + +http://inamidst.com/phenny/ +""" + +import urllib + +def swhack(phenny, input): + if not input.sender in ('#swhack', '#inamidst'): + return + + query = input.group(2) + pattern = urllib.quote(query, safe='./') + + u = urllib.urlopen('http://swhack.com/scripts/tail/' + pattern) + + i = None + for i, line in enumerate(u.readlines()): + line = line.rstrip('\r\n') + if i == 0: + phenny.reply(line) + else: phenny.say('[off] ' + line) + if i is None: + phenny.reply('Sorry, no results found.') + + u.close() +swhack.commands = ['swhack'] + +if __name__ == '__main__': + print __doc__.strip() -- cgit v1.2.3-1-g7c22