Enforce space after emote URLs (#149)

Enclose emoji URLs in brackets.

Discord allows emoji to be sent back to back without any delimiters resulting in botched urls. Add <> brackets so that emoji urls are separated from the rest of the text.
This commit is contained in:
Alcaro 2018-05-17 12:19:53 +02:00 committed by Artem Savkov
parent 020fe0f0b5
commit ae2177abd5
1 changed files with 2 additions and 2 deletions

View File

@ -675,14 +675,14 @@ static gboolean discord_prepare_message(struct im_connection *ic,
// Replace animated emoji with code and a URL
GRegex *emoji_regex_a = g_regex_new("<a(:[^:]+:)(\\d+)>", 0, 0, NULL);
gchar *emoji_msg_a = g_regex_replace(emoji_regex_a, msg, -1, 0, "\\1 https://cdn.discordapp.com/emojis/\\2.gif", 0, NULL);
gchar *emoji_msg_a = g_regex_replace(emoji_regex_a, msg, -1, 0, "\\1 <https://cdn.discordapp.com/emojis/\\2.gif>", 0, NULL);
g_free(msg);
msg = emoji_msg_a;
g_regex_unref(emoji_regex_a);
// Replace custom emoji with code and a URL
GRegex *emoji_regex = g_regex_new("<(:[^:]+:)(\\d+)>", 0, 0, NULL);
gchar *emoji_msg = g_regex_replace(emoji_regex, msg, -1, 0, "\\1 https://cdn.discordapp.com/emojis/\\2.png", 0, NULL);
gchar *emoji_msg = g_regex_replace(emoji_regex, msg, -1, 0, "\\1 <https://cdn.discordapp.com/emojis/\\2.png>", 0, NULL);
g_free(msg);
msg = emoji_msg;
g_regex_unref(emoji_regex);