summaryrefslogtreecommitdiffstats
path: root/opt/swhack.py
blob: 60914c0a40adff006d80e64eaa42a414e1eefc88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()