From 702d160c466e7a873fdda381b8213f8852e60df5 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Fri, 7 Oct 2016 15:26:13 +0100 Subject: [PATCH] Dedup and improve identification. --- bot.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 2d2f071..662fd45 100755 --- a/bot.py +++ b/bot.py @@ -371,8 +371,12 @@ def identify(destination, target): break else: for member in client.get_all_members(): - if target and member.name != target: - continue + if target: + parts = target.lower().split('#') + if member.name.lower() != parts[0]: + continue + if len(parts) > 1 and member.discriminator != parts[1]: + continue results.append(member) if do & Identify.role.value: if role_id: @@ -384,7 +388,7 @@ def identify(destination, target): else: for server in client.servers: for role in server.roles: - if target and role.name != target: + if target and role.name.lower() != target.lower(): continue results.append(role) if do & Identify.channel.value: @@ -394,11 +398,11 @@ def identify(destination, target): results.append(channel) else: for channel in client.get_all_channels(): - if target and channel.name != target: + if target and channel.name.lower() != target.lower(): continue results.append(channel) - yield from say_many(destination, ['{} {} {}'.format(Identify.string(result), result.id, result.name) for result in results]) + yield from say_many(destination, ['{} {} {}'.format(Identify.string(result), result.id, result.name) for result in set(results)]) @asyncio.coroutine def do_commands(message, command, raw, non_admin): -- 2.7.4