From aa5a4fa79a3fb816d66865f50784cf6a4ed2e4bb Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sun, 4 Mar 2018 08:10:15 +0000 Subject: [PATCH] Gif avatars for user cards --- webapp/titanembeds/blueprints/api/api.py | 2 +- webapp/titanembeds/oauth.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp/titanembeds/blueprints/api/api.py b/webapp/titanembeds/blueprints/api/api.py index d4f4f9c..1cee11a 100644 --- a/webapp/titanembeds/blueprints/api/api.py +++ b/webapp/titanembeds/blueprints/api/api.py @@ -140,7 +140,7 @@ def get_online_embed_users(guild_id): 'username': usrdb.username, 'nickname': usrdb.nickname, 'discriminator': usrdb.discriminator, - 'avatar_url': generate_avatar_url(usrdb.user_id, usrdb.avatar), + 'avatar_url': generate_avatar_url(usrdb.user_id, usrdb.avatar, "0000", True), } users['authenticated'].append(meta) return users diff --git a/webapp/titanembeds/oauth.py b/webapp/titanembeds/oauth.py index a6f121b..3d08334 100644 --- a/webapp/titanembeds/oauth.py +++ b/webapp/titanembeds/oauth.py @@ -95,8 +95,10 @@ def check_user_permission(guild_id, id): return user_has_permission(guild['permissions'], id) or guild['owner'] return False -def generate_avatar_url(id, av, discrim="0000"): +def generate_avatar_url(id, av, discrim="0000", allow_animate=False): if av: + if allow_animate && str(av).startswith("a_"): + return avatar_base_url + str(id) + '/' + str(av) + '.gif' return avatar_base_url + str(id) + '/' + str(av) + '.png' else: default_av = [0, 1, 2, 3, 4]