Merge branch 'master' into forum-parsing
This commit is contained in:
@@ -237,25 +237,33 @@ def command_unicode_lookup(argv, **args):
|
|||||||
return {
|
return {
|
||||||
'msg': args['reply_user'] + ': usage: decode {single character}'
|
'msg': args['reply_user'] + ': usage: decode {single character}'
|
||||||
}
|
}
|
||||||
search_word = argv[1]
|
search_words = argv[1:]
|
||||||
|
|
||||||
import unicode
|
import unicode
|
||||||
|
|
||||||
characters = {
|
characters = {
|
||||||
k: v for k, v in unicode.characters.items() if
|
k: v for k, v in unicode.characters.items() if
|
||||||
search_word.lower() in v.lower().split()
|
all([word.lower() in v.lower().split() for word in search_words])
|
||||||
}
|
}
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
for code, name in characters.items():
|
for code, name in characters.items():
|
||||||
char = chr(int(code, 16))
|
char = chr(int(code, 16))
|
||||||
lines.append("Character \"{}\" with code {} is named \"{}\"".format(char, code, name))
|
lines.append("Character \"{}\" with code {} is named \"{}\"".format(char, code, name))
|
||||||
if len(lines) > 9:
|
if len(lines) > 29:
|
||||||
lines.append("warning: limit (10) reached.")
|
lines.append("warning: limit (30) reached.")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not lines:
|
||||||
|
return {
|
||||||
|
'msg': 'No match.'
|
||||||
|
}
|
||||||
|
elif len(lines) > 3:
|
||||||
|
channel = 'priv_msg'
|
||||||
|
else:
|
||||||
|
channel = 'msg'
|
||||||
return {
|
return {
|
||||||
'msg': lines
|
channel: lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user