Animated Emoji Support, Closes #85

This commit is contained in:
Jeremy Zhang 2018-03-01 07:57:45 +00:00
parent b61d249fe6
commit 63979835ab
4 changed files with 16 additions and 6 deletions

View File

@ -44,7 +44,8 @@ def get_emojis_list(guildemojis):
"require_colons": emote.require_colons,
"managed": emote.managed,
"roles": list_role_ids(emote.roles),
"url": emote.url
"url": emote.url,
"animated": emote.animated
})
return emojis

View File

@ -21,7 +21,11 @@ def parse_emoji(textToParse, guild_id):
for gemoji in guild_emojis:
emoji_name = gemoji["name"]
emoji_id = gemoji["id"]
textToParse = textToParse.replace(":{}:".format(emoji_name), "<:{}:{}>".format(emoji_name, emoji_id))
emoji_animated = gemoji["animated"]
if emoji_animated:
textToParse = textToParse.replace(":{}:".format(emoji_name), "<a:{}:{}>".format(emoji_name, emoji_id))
else:
textToParse = textToParse.replace(":{}:".format(emoji_name), "<:{}:{}>".format(emoji_name, emoji_id))
return textToParse

View File

@ -212,7 +212,7 @@
Mustache.parse(template);
for (var i = 0; i < emoji_store.length; i++) {
var emoji = emoji_store[i];
var rendered = Mustache.render(template, {"id": emoji.id, "name": emoji.name}).trim();
var rendered = Mustache.render(template, {"id": emoji.id, "name": emoji.name, "animated": emoji.animated}).trim();
var jqueryed = $(rendered);
jqueryed.click(function () {
var emote_name = $(this).attr("data-tooltip");
@ -995,8 +995,13 @@
Mustache.parse(template);
for (var i = 0; i < emoji_store.length; i++) {
var emoji = emoji_store[i];
var emoji_format = "&lt;:" + emoji.name + ":" + emoji.id + "&gt;";
var rendered = Mustache.render(template, {"id": emoji.id, "name": emoji.name}).trim();
var emoji_format = "";
if (emoji.animated) {
emoji_format = "&lt;a:" + emoji.name + ":" + emoji.id + "&gt;";
} else {
emoji_format = "&lt;:" + emoji.name + ":" + emoji.id + "&gt;";
}
var rendered = Mustache.render(template, {"id": emoji.id, "name": emoji.name, "animated": emoji.animated}).trim();
message.content = message.content.replaceAll(emoji_format, rendered);
}
var rendered = Mustache.render(template, {"id": "$2", "name": "$1"}).trim();

View File

@ -322,7 +322,7 @@
</script>
<script id="mustache_message_emoji" type="text/template">
<img class="message_emoji tooltipped" src='https://cdn.discordapp.com/emojis/{{id}}.png' data-position="top" data-delay="200" data-tooltip=":{{name}}:" alt=":{{name}}:" />
<img class="message_emoji tooltipped" src='https://cdn.discordapp.com/emojis/{{id}}{{#animated}}.gif{{/animated}}{{^animated}}.png{{/animated}}' data-position="top" data-delay="200" data-tooltip=":{{name}}:" alt=":{{name}}:" />
</script>
<script id="mustache_discordmention" type="text/template">