From fb5795335d46866d5941584b3930ddd210fdd90f Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 31 Dec 2015 15:45:11 +0100 Subject: [PATCH] search for all words in unicode-lookup, return priv_msg if len > 3 --- plugins/commands.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index 35c32d2..b93efbc 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -237,25 +237,33 @@ def command_unicode_lookup(argv, **args): return { 'msg': args['reply_user'] + ': usage: decode {single character}' } - search_word = argv[1] + search_words = argv[1:] import unicode characters = { 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 = [] for code, name in characters.items(): char = chr(int(code, 16)) lines.append("Character \"{}\" with code {} is named \"{}\"".format(char, code, name)) - if len(lines) > 9: - lines.append("warning: limit (10) reached.") + if len(lines) > 29: + lines.append("warning: limit (30) reached.") break + if not lines: + return { + 'msg': 'No match.' + } + elif len(lines) > 3: + channel = 'priv_msg' + else: + channel = 'msg' return { - 'msg': lines + channel: lines }