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 from lxml import etree
import urllib import urllib
host = 'http://bigassmessage.com'
@hook.command @hook.command
def bam(inp): def bam(inp):
"""[basic|magic|pepsi|jprdy] bigassify this"""
if not inp: if not inp:
return 'you forgot something' return bam.__doc__
inp = urllib.quote_plus(inp) host = 'http://bigassmessage.com'
path = '/dsx_BAM/boe.php?action=saveMsg&theStyle=magic&theMessage=' + inp path = '/dsx_BAM/boe.php'
url = host + path 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: try:
response = etree.parse(url) response = etree.parse(url)