added docstring, returning it if no input given, using style if specified by first word in input

This commit is contained in:
epswing 2010-03-14 04:55:48 -04:00
parent 441994fa34
commit 1a9a6b4ad1
1 changed files with 14 additions and 6 deletions

View File

@ -2,18 +2,26 @@ from util import hook
from lxml import etree
import urllib
host = 'http://bigassmessage.com'
@hook.command
def bam(inp):
"""[basic|magic|pepsi|jprdy] bigassify this"""
if not inp:
return 'you forgot something'
return bam.__doc__
inp = urllib.quote_plus(inp)
path = '/dsx_BAM/boe.php?action=saveMsg&theStyle=magic&theMessage=' + inp
url = host + path
host = 'http://bigassmessage.com'
path = '/dsx_BAM/boe.php'
params = {'action': 'saveMsg', 'theStyle': 'basic', 'theMessage': inp}
styles = ['basic', 'magic', 'pepsi', 'jprdy']
for style in styles:
if inp.startswith(style + ' '):
params['theStyle'] = style
params['theMessage'] = inp[len(style) + 1:]
url = host + path + '?' + urllib.urlencode(params)
try:
response = etree.parse(url)