mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 02:45:08 -04:00
Update twemoji URLs
This commit is contained in:
parent
f29e1d2d9f
commit
9aba36fce5
2 changed files with 14 additions and 12 deletions
|
@ -11,12 +11,12 @@ namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
public partial record Emoji(
|
public partial record Emoji(
|
||||||
// Only present on custom emoji
|
// Only present on custom emoji
|
||||||
Snowflake? Id,
|
Snowflake? Id,
|
||||||
// Name of custom emoji (e.g. LUL) or actual representation of standard emoji (e.g. 🙂)
|
// Name of a custom emoji (e.g. LUL) or actual representation of a standard emoji (e.g. 🙂)
|
||||||
string Name,
|
string Name,
|
||||||
bool IsAnimated,
|
bool IsAnimated,
|
||||||
string ImageUrl)
|
string ImageUrl)
|
||||||
{
|
{
|
||||||
// Name of custom emoji (e.g. LUL) or name of standard emoji (e.g. slight_smile)
|
// Name of a custom emoji (e.g. LUL) or name of a standard emoji (e.g. slight_smile)
|
||||||
public string Code => Id is not null
|
public string Code => Id is not null
|
||||||
? Name
|
? Name
|
||||||
: EmojiIndex.TryGetCode(Name) ?? Name;
|
: EmojiIndex.TryGetCode(Name) ?? Name;
|
||||||
|
@ -24,17 +24,19 @@ public partial record Emoji(
|
||||||
|
|
||||||
public partial record Emoji
|
public partial record Emoji
|
||||||
{
|
{
|
||||||
private static string GetTwemojiName(string name)
|
private static string GetTwemojiId(string name)
|
||||||
{
|
{
|
||||||
var runes = name.GetRunes();
|
var runes = name.GetRunes().ToArray();
|
||||||
|
|
||||||
|
// Variant selector rune is skipped in Twemoji names, except when the emoji also contains a zero-width joiner.
|
||||||
|
// VS = 0xfe0f; ZWJ = 0x200d.
|
||||||
|
var filteredRunes = runes.Any(r => r.Value == 0x200d)
|
||||||
|
? runes
|
||||||
|
: runes.Where(r => r.Value != 0xfe0f);
|
||||||
|
|
||||||
return string.Join(
|
return string.Join(
|
||||||
"-",
|
"-",
|
||||||
// Variant selector rune is skipped in Twemoji names, except when the emoji also contains a zero-width joiner.
|
filteredRunes.Select(r => r.Value.ToString("x"))
|
||||||
// VS = 0xfe0f. ZWJ = 0x200d.
|
|
||||||
runes.Any(r => r.Value == 0x200d)
|
|
||||||
? runes.Select(r => r.Value.ToString("x"))
|
|
||||||
: runes.Where(r => r.Value != 0xfe0f).Select(r => r.Value.ToString("x"))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ public partial record Emoji
|
||||||
: $"https://cdn.discordapp.com/emojis/{id}.png";
|
: $"https://cdn.discordapp.com/emojis/{id}.png";
|
||||||
|
|
||||||
private static string GetImageUrl(string name) =>
|
private static string GetImageUrl(string name) =>
|
||||||
$"https://twemoji.maxcdn.com/2/svg/{GetTwemojiName(name)}.svg";
|
$"https://twemoji.maxcdn.com/v/latest/svg/{GetTwemojiId(name)}.svg";
|
||||||
|
|
||||||
public static string GetImageUrl(Snowflake? id, string? name, bool isAnimated)
|
public static string GetImageUrl(Snowflake? id, string? name, bool isAnimated)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,13 @@ namespace DiscordChatExporter.Core.Markdown;
|
||||||
internal record EmojiNode(
|
internal record EmojiNode(
|
||||||
// Only present on custom emoji
|
// Only present on custom emoji
|
||||||
Snowflake? Id,
|
Snowflake? Id,
|
||||||
// Name of custom emoji (e.g. LUL) or actual representation of standard emoji (e.g. 🙂)
|
// Name of a custom emoji (e.g. LUL) or actual representation of a standard emoji (e.g. 🙂)
|
||||||
string Name,
|
string Name,
|
||||||
bool IsAnimated) : MarkdownNode
|
bool IsAnimated) : MarkdownNode
|
||||||
{
|
{
|
||||||
public bool IsCustomEmoji => Id is not null;
|
public bool IsCustomEmoji => Id is not null;
|
||||||
|
|
||||||
// Name of custom emoji (e.g. LUL) or name of standard emoji (e.g. slight_smile)
|
// Name of a custom emoji (e.g. LUL) or name of a standard emoji (e.g. slight_smile)
|
||||||
public string Code => IsCustomEmoji
|
public string Code => IsCustomEmoji
|
||||||
? Name
|
? Name
|
||||||
: EmojiIndex.TryGetCode(Name) ?? Name;
|
: EmojiIndex.TryGetCode(Name) ?? Name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue