1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

search for all words in unicode-lookup, return priv_msg if len > 3

This commit is contained in:
Thorsten
2015-12-31 15:45:11 +01:00
parent 35158a623d
commit fb5795335d

View File

@@ -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 { return {
'msg': lines 'msg': 'No match.'
}
elif len(lines) > 3:
channel = 'priv_msg'
else:
channel = 'msg'
return {
channel: lines
} }