Repository navigation
Expand file tree
/
Copy pathcomponent_emojis.py
More file actions
61 lines (52 loc) · 2.19 KB
/
Copy pathcomponent_emojis.py
File metadata and controls
61 lines (52 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Shared Discord application emojis for Components V2 cards."""
from __future__ import annotations
from typing import Final, Optional
APPLICATION_EMOJI_IDS: Final[dict[str, int]] = {
"quote": 1526256046786609164,
"upvote": 1526256000641007616,
"downvote": 1526255999210487859,
"coins": 1526369937013342350,
"bookmark": 1526255813268733962,
"views": 1526255708683636896,
"like": 1526255244483362866,
"repost": 1526255036072591450,
"comment": 1526254715250282506,
"share": 1527880479305498744,
"note": 1527889882746323094,
"download": 1528175452559118537,
"x_government": 1527644261208690778,
"x_premium": 1527644259308798113,
"x_organization": 1527642128300118129,
}
def application_emoji(name: str) -> str:
"""Return Discord markup for a named FixEmbed application emoji."""
return f"<:{name}:{APPLICATION_EMOJI_IDS[name]}>"
def format_component_stats(stats: str, platform: Optional[str] = None) -> str:
"""Replace portable Unicode activity icons with FixEmbed application emojis."""
replacements = (
("\U0001f4ac", "comment"),
("\U0001f44d", "like"),
("\U0001f501", "repost"),
("\u2764\ufe0f", "like"),
("\u2764", "like"),
("\U0001f441\ufe0f", "views"),
("\U0001f441", "views"),
("\U0001fa99", "coins"),
("\U0001f516", "bookmark"),
)
rendered = stats
for portable_icon, emoji_name in replacements:
rendered = rendered.replace(portable_icon, application_emoji(emoji_name))
if platform and platform.casefold() == "reddit":
rendered = rendered.replace(application_emoji("like"), application_emoji("upvote"))
if platform and platform.casefold() == "tiktok":
rendered = rendered.replace(application_emoji("repost"), application_emoji("share"))
if platform and platform.casefold() == "tumblr":
rendered = rendered.replace("\U0001f4dd", application_emoji("note"))
if platform and platform.casefold() == "deviantart":
rendered = rendered.replace(
"\u2b07\ufe0f",
application_emoji("download"),
)
rendered = rendered.replace("\u2b07", application_emoji("download"))
return rendered