diff options
author | Sean B. Palmer <http://inamidst.com/sbp/> | 2008-02-23 12:17:06 +0000 |
---|---|---|
committer | Sean B. Palmer <http://inamidst.com/sbp/> | 2008-02-23 12:17:06 +0000 |
commit | cbdf9ebd7312bf570a212057ad793ae520bac38f (patch) | |
tree | f867f731825daaa2104c204d96fd3c7c8d44664c /opt | |
parent | 2fb00589439a4efb3906d4e681e7ed815dcd180a (diff) | |
download | bot-cbdf9ebd7312bf570a212057ad793ae520bac38f.tar.gz bot-cbdf9ebd7312bf570a212057ad793ae520bac38f.tar.bz2 bot-cbdf9ebd7312bf570a212057ad793ae520bac38f.zip |
And some new modules too...
Diffstat (limited to 'opt')
-rw-r--r-- | opt/swhack.py | 34 |
1 files changed, 34 insertions, 0 deletions
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() |