From 441994fa342bcdeb9746781ddb353c14451a02c3 Mon Sep 17 00:00:00 2001 From: epswing Date: Sun, 14 Mar 2010 04:01:34 -0400 Subject: [PATCH] tabs to spaces, using urllib.quote, inp no longer needlessly stripped, if statements no longer using parens, spacing modified to pass pep8 --- plugins/bigassmessage.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/plugins/bigassmessage.py b/plugins/bigassmessage.py index 8e324b7..6e5645e 100644 --- a/plugins/bigassmessage.py +++ b/plugins/bigassmessage.py @@ -1,25 +1,26 @@ from util import hook from lxml import etree -import urllib2 +import urllib host = 'http://bigassmessage.com' + @hook.command def bam(inp): - - if not inp: - return 'you forgot something' - - inp = inp.strip().replace(' ', '+') - path = '/dsx_BAM/boe.php?action=saveMsg&theStyle=magic&theMessage=' + inp - url = host + path - - try: - response = etree.parse(urllib2.urlopen(url)) - status = response.xpath('//status/text()')[0] - if (status == 'ok'): - return host + '/' + response.xpath('//msgid/text()')[0] - else: - return response.xpath('//message/text()')[0] - except: - pass + + if not inp: + return 'you forgot something' + + inp = urllib.quote_plus(inp) + path = '/dsx_BAM/boe.php?action=saveMsg&theStyle=magic&theMessage=' + inp + url = host + path + + try: + response = etree.parse(url) + status = response.xpath('//status/text()')[0] + if status == 'ok': + return host + '/' + response.xpath('//msgid/text()')[0] + else: + return response.xpath('//message/text()')[0] + except: + pass