tabs to spaces, using urllib.quote, inp no longer needlessly stripped, if statements no longer using parens, spacing modified to pass pep8
This commit is contained in:
parent
90923ac404
commit
441994fa34
|
@ -1,23 +1,24 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import urllib2
|
import urllib
|
||||||
|
|
||||||
host = 'http://bigassmessage.com'
|
host = 'http://bigassmessage.com'
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def bam(inp):
|
def bam(inp):
|
||||||
|
|
||||||
if not inp:
|
if not inp:
|
||||||
return 'you forgot something'
|
return 'you forgot something'
|
||||||
|
|
||||||
inp = inp.strip().replace(' ', '+')
|
inp = urllib.quote_plus(inp)
|
||||||
path = '/dsx_BAM/boe.php?action=saveMsg&theStyle=magic&theMessage=' + inp
|
path = '/dsx_BAM/boe.php?action=saveMsg&theStyle=magic&theMessage=' + inp
|
||||||
url = host + path
|
url = host + path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = etree.parse(urllib2.urlopen(url))
|
response = etree.parse(url)
|
||||||
status = response.xpath('//status/text()')[0]
|
status = response.xpath('//status/text()')[0]
|
||||||
if (status == 'ok'):
|
if status == 'ok':
|
||||||
return host + '/' + response.xpath('//msgid/text()')[0]
|
return host + '/' + response.xpath('//msgid/text()')[0]
|
||||||
else:
|
else:
|
||||||
return response.xpath('//message/text()')[0]
|
return response.xpath('//message/text()')[0]
|
||||||
|
|
Loading…
Reference in New Issue