Fix emoji not replacing or rendering, also fix visitor fetching 429 error

This commit is contained in:
Jeremy Zhang 2017-06-10 03:43:23 +00:00
parent fbe41a9a35
commit 289fdc0eb5
2 changed files with 13 additions and 11 deletions

View File

@ -100,17 +100,12 @@ def check_user_in_guild(guild_id):
return dbUser is not None and not checkUserRevoke(guild_id)
def parse_emoji(textToParse, guild_id):
emojis = []
emojis = re.findall(":(.*?):", textToParse)
guild_emojis = get_guild_emojis(guild_id)
newText = textToParse
for gemoji in guild_emojis:
emoji_name = gemoji["name"]
emoji_id = gemoji["id"]
for usremote in emojis:
if usremote == emoji_name:
newText = newText.replace(":{}:".format(emoji_name), "<:{}:{}>".format(emoji_name, emoji_id))
return newText
textToParse = textToParse.replace(":{}:".format(emoji_name), "<:{}:{}>".format(emoji_name, emoji_id))
return textToParse
def format_post_content(guild_id, message):

View File

@ -38,6 +38,10 @@
}
}
String.prototype.replaceAll = function(target, replacement) {
return this.split(target).join(replacement);
};
function query_guild() {
var url = "/api/query_guild";
if (visitor_mode) {
@ -533,7 +537,7 @@
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();
message.content = message.content.replace(emoji_format, rendered);
message.content = message.content.replaceAll(emoji_format, rendered);
}
return message;
}
@ -621,10 +625,13 @@
$('#loginmodal').modal('open');
Materialize.toast('Session expired! You have been logged out.', 10000);
}
if (data.status != 429) {
setVisitorMode(true);
if (visitor_mode) {
fetchtimeout = setTimeout(run_fetch_routine, 5000);
}
}
});
fet.catch(function(data) {
if (500 <= data.status && data.status < 600) {