From 7eaf976b38dee17039666a1ec5a2da69fd7ac0fe Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Wed, 28 Sep 2016 15:45:08 +0100 Subject: [PATCH] Mention user whose avatar was blinged. --- bot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index e37a39e..664e681 100755 --- a/bot.py +++ b/bot.py @@ -201,18 +201,17 @@ def do_commands(message, command, raw, non_admin): log.debug('No URL for avatar') yield from say(message.channel, 'zzz') return - fd = open_url(url) - if fd is None: - log.debug('Failed to open URL {} for avatar'.format(url)) + result = yield from set_avatar(url) + if not result: yield from say(message.channel, 'yelp!') return - yield from client.edit_profile(avatar = fd.read()) - fd.close() elif command == 'bling': # bling url = None m = re.match(r'\bbling\s+(\S+)', raw.lower()) + filename = message.author.name + mentions = [message.author.mention] if message.channel.is_private else None if m is not None: url = m.group(1) m = re.match(r'<@(!?\d+)>', url) @@ -226,6 +225,9 @@ def do_commands(message, command, raw, non_admin): log.warning("Can't see requested user {}".format(url)) url = None else: + if mentions is not None: + filename = other.name + mentions.append(other.mention) url = other.avatar_url elif len(message.attachments): url = message.attachments[0]['url'] @@ -241,7 +243,7 @@ def do_commands(message, command, raw, non_admin): if data is None: yield from say(message.channel, 'yelp!') return - yield from client.send_file(message.channel, data, filename = message.author.name + '.png', content = message.author.mention if not message.channel.is_private else 'purr') + yield from client.send_file(message.channel, data, filename = filename + '.png', content = ' '.join(mentions) if mentions is not None else 'purr') return elif command == 'debug': -- 2.7.4