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
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from util import hook
|
||||
|
||||
|
||||
@hook.command
|
||||
def bam(inp):
|
||||
|
@ -10,25 +12,21 @@ def bam(inp):
|
|||
if not inp:
|
||||
return bam.__doc__
|
||||
|
||||
host = 'http://bigassmessage.com'
|
||||
path = '/dsx_BAM/boe.php'
|
||||
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 + ' '):
|
||||
if ' ' in inp:
|
||||
style, message = inp.split(None, 1)
|
||||
if style in ['basic', 'magic', 'pepsi', 'jprdy']:
|
||||
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)
|
||||
status = response.xpath('//status/text()')[0]
|
||||
if status == 'ok':
|
||||
return host + '/' + response.xpath('//msgid/text()')[0]
|
||||
return host + response.xpath('//msgid/text()')[0]
|
||||
else:
|
||||
return response.xpath('//message/text()')[0]
|
||||
except:
|
||||
pass
|
||||
|
|
|
@ -11,9 +11,10 @@ from util import hook
|
|||
|
||||
|
||||
@hook.command('val')
|
||||
@hook.command('valid')
|
||||
@hook.command
|
||||
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:
|
||||
return validate.__doc__
|
||||
|
@ -31,5 +32,3 @@ def validate(inp):
|
|||
warningcount = info['x-w3c-validator-warnings']
|
||||
return "%s was found to be %s with %s errors and %s warnings." \
|
||||
" see: %s" % (inp, status, errorcount, warningcount, url)
|
||||
else:
|
||||
return "Something went wrong while validating %s" % inp
|
||||
|
|
Loading…
Reference in New Issue