feat: initial commit

This commit is contained in:
Sofía Maturana 2026-05-21 15:57:47 -04:00
commit bfc55bf2a5
5 changed files with 63 additions and 0 deletions

13
.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv
# Endcord stubs
stubs/

1
.python-version Normal file
View file

@ -0,0 +1 @@
3.13

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# endcord-aemoji
An animated emoji viewer for [endcord](https://github.com/sparklost/endcord)

36
endcord_aemoji.py Normal file
View file

@ -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)

10
pyproject.toml Normal file
View file

@ -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/"]