decode: cleanup, decode multiple characters at once
This commit is contained in:
36
plugins.py
36
plugins.py
@@ -472,21 +472,33 @@ def command_decode(argv, **args):
|
|||||||
'msg': args['reply_user'] + ': usage: decode {single character}'
|
'msg': args['reply_user'] + ': usage: decode {single character}'
|
||||||
}
|
}
|
||||||
|
|
||||||
char = argv[1]
|
log.plugin('decode called for %s' % argv[1])
|
||||||
char_esc = str(char.encode('unicode_escape'))[3:-1]
|
|
||||||
log.plugin('decode called for %s' % char)
|
|
||||||
|
|
||||||
try:
|
out = []
|
||||||
uni_name = unicodedata.name(char)
|
for i, char in enumerate(argv[1]):
|
||||||
except Exception as e:
|
if i > 9:
|
||||||
log.plugin('decode(%s) failed: %s' % (char, str(e)))
|
out.append('... limit reached.')
|
||||||
|
break
|
||||||
|
|
||||||
|
char_esc = str(char.encode('unicode_escape'))[3:-1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
uni_name = unicodedata.name(char)
|
||||||
|
except Exception as e:
|
||||||
|
log.plugin('decode(%s) failed: %s' % (char, e))
|
||||||
|
out.append("can't decode %s (%s): %s" % (char, char_esc, e))
|
||||||
|
continue
|
||||||
|
|
||||||
|
out.append('%s (%s) is called "%s"' % (char, char_esc, uni_name))
|
||||||
|
|
||||||
|
if 1 == len(out):
|
||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ": can't decode %s (%s): %s" % (char, char_esc, str(e))
|
'msg': args['reply_user'] + ': %s' % out[0]
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
'msg': [args['reply_user'] + ': decoding %s:' % argv[1]] + out
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
'msg': args['reply_user'] + ': %s (%s) is called "%s"' % (char, char_esc, uni_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
@pluginfunction('show-blacklist', 'show the current URL blacklist, optionally filtered', ptypes_COMMAND)
|
@pluginfunction('show-blacklist', 'show the current URL blacklist, optionally filtered', ptypes_COMMAND)
|
||||||
def command_show_blacklist(argv, **args):
|
def command_show_blacklist(argv, **args):
|
||||||
|
|||||||
Reference in New Issue
Block a user