mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-19 13:21:32 +00:00
@@ -1,10 +1,12 @@
|
||||
using Tyrrrz.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Tyrrrz.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Models
|
||||
{
|
||||
// https://discordapp.com/developers/docs/resources/emoji#emoji-object
|
||||
|
||||
public class Emoji
|
||||
public partial class Emoji
|
||||
{
|
||||
public string Id { get; }
|
||||
|
||||
@@ -28,8 +30,7 @@ namespace DiscordChatExporter.Core.Models
|
||||
}
|
||||
|
||||
// Standard unicode emoji (via twemoji)
|
||||
var codePoint = char.ConvertToUtf32(Name, 0).ToString("x");
|
||||
return $"https://twemoji.maxcdn.com/2/72x72/{codePoint}.png";
|
||||
return $"https://twemoji.maxcdn.com/2/72x72/{GetTwemojiName(Name)}.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +41,16 @@ namespace DiscordChatExporter.Core.Models
|
||||
IsAnimated = isAnimated;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Emoji
|
||||
{
|
||||
private static IEnumerable<int> GetCodePoints(string emoji)
|
||||
{
|
||||
for (var i = 0; i < emoji.Length; i += char.IsHighSurrogate(emoji[i]) ? 2 : 1)
|
||||
yield return char.ConvertToUtf32(emoji, i);
|
||||
}
|
||||
|
||||
private static string GetTwemojiName(string emoji)
|
||||
=> GetCodePoints(emoji).Select(i => i.ToString("x")).JoinToString("-");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user