From bfc55bf2a51f13915c99af25744c293a4fef11dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sof=C3=ADa=20Maturana?= Date: Thu, 21 May 2026 15:57:47 -0400 Subject: [PATCH] feat: initial commit --- .gitignore | 13 +++++++++++++ .python-version | 1 + README.md | 3 +++ endcord_aemoji.py | 36 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 10 ++++++++++ 5 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 .python-version create mode 100644 README.md create mode 100644 endcord_aemoji.py create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b09a921 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv + +# Endcord stubs +stubs/ diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ef7494 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# endcord-aemoji + +An animated emoji viewer for [endcord](https://github.com/sparklost/endcord) diff --git a/endcord_aemoji.py b/endcord_aemoji.py new file mode 100644 index 0000000..16e3ddf --- /dev/null +++ b/endcord_aemoji.py @@ -0,0 +1,36 @@ +import re +from endcord.app import Endcord + +EXT_NAME = "endcord_aemoji" +EXT_VERSION = "0.1.0" +EXT_ENDCORD_VERSION = "1.4.2" +EXT_DESCRIPTION = "View animated custom emoji as GIFs" +EXT_COMMAND_ASSIST = ("view_aemoji - View animated emoji", "view_aemoji") + +EMOJI_RE = re.compile("^<:(.+):(\d+)>$") + + +def get_emoji_url(emoji: str) -> str | None: + m = EMOJI_RE.fullmatch(emoji) + if m is None: + return None + emoji_id = m.group(2) + return f"https://cdn.discordapp.com/emojis/{emoji}.gif" + + +class Extension: + def __init__(self, app): + self.app: Endcord = app + + def on_execute_command(self, command_text: str, chat_sel: int, tree_sel: int): + if command_text.startswith("view_aemoji"): + try: + emoji = command_text.split(" ")[1] + except IndexError: + self.app.update_extra_line("Emoji argument not given") + return + emoji_url = get_emoji_url(emoji) + if emoji_url is None: + self.app.update_extra_line("Invalid emoji") + return + self.app.download_file(emoji_url, open_media=True) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..927ed6d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[project] +name = "endcord-aemoji" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [] + +[tool.ty.environment] +extra-paths = ["./stubs/"]