From 1a9a6b4ad1f667d7b54c7b470b06b4daf568dabb Mon Sep 17 00:00:00 2001 From: epswing Date: Sun, 14 Mar 2010 04:55:48 -0400 Subject: [PATCH] added docstring, returning it if no input given, using style if specified by first word in input --- plugins/bigassmessage.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/bigassmessage.py b/plugins/bigassmessage.py index 6e5645e..5d15ff3 100644 --- a/plugins/bigassmessage.py +++ b/plugins/bigassmessage.py @@ -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)