fix validate plugin's handling of http-less urls, clean bigassmessage
This commit is contained in:
parent
0935a72c16
commit
278bc2e13a
|
@ -1,7 +1,9 @@
|
||||||
from util import hook
|
|
||||||
from lxml import etree
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
from util import hook
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def bam(inp):
|
def bam(inp):
|
||||||
|
@ -10,25 +12,21 @@ def bam(inp):
|
||||||
if not inp:
|
if not inp:
|
||||||
return bam.__doc__
|
return bam.__doc__
|
||||||
|
|
||||||
host = 'http://bigassmessage.com'
|
host = 'http://bigassmessage.com/'
|
||||||
path = '/dsx_BAM/boe.php'
|
path = 'dsx_BAM/boe.php?'
|
||||||
params = {'action': 'saveMsg', 'theStyle': 'basic', 'theMessage': inp}
|
params = {'action': 'saveMsg', 'theStyle': 'basic', 'theMessage': inp}
|
||||||
|
|
||||||
styles = ['basic', 'magic', 'pepsi', 'jprdy']
|
if ' ' in inp:
|
||||||
|
style, message = inp.split(None, 1)
|
||||||
for style in styles:
|
if style in ['basic', 'magic', 'pepsi', 'jprdy']:
|
||||||
if inp.startswith(style + ' '):
|
|
||||||
params['theStyle'] = style
|
params['theStyle'] = style
|
||||||
params['theMessage'] = inp[len(style) + 1:]
|
params['theMessage'] = message
|
||||||
|
|
||||||
url = host + path + '?' + urllib.urlencode(params)
|
url = host + path + urllib.urlencode(params)
|
||||||
|
|
||||||
try:
|
|
||||||
response = etree.parse(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]
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
|
@ -11,9 +11,10 @@ from util import hook
|
||||||
|
|
||||||
|
|
||||||
@hook.command('val')
|
@hook.command('val')
|
||||||
|
@hook.command('valid')
|
||||||
@hook.command
|
@hook.command
|
||||||
def validate(inp):
|
def validate(inp):
|
||||||
'''.val/.validate <url> -- runs url through the w3c markup validator'''
|
'''.val/.valid/.validate <url> -- runs url through w3c markup validator'''
|
||||||
|
|
||||||
if not inp:
|
if not inp:
|
||||||
return validate.__doc__
|
return validate.__doc__
|
||||||
|
@ -31,5 +32,3 @@ def validate(inp):
|
||||||
warningcount = info['x-w3c-validator-warnings']
|
warningcount = info['x-w3c-validator-warnings']
|
||||||
return "%s was found to be %s with %s errors and %s warnings." \
|
return "%s was found to be %s with %s errors and %s warnings." \
|
||||||
" see: %s" % (inp, status, errorcount, warningcount, url)
|
" see: %s" % (inp, status, errorcount, warningcount, url)
|
||||||
else:
|
|
||||||
return "Something went wrong while validating %s" % inp
|
|
||||||
|
|
Loading…
Reference in New Issue