fix: match command correctly

This commit is contained in:
Sofía Maturana 2026-05-21 16:17:14 -04:00
parent c000d75111
commit 7496c43161

View file

@ -6,7 +6,7 @@ EXT_VERSION = "0.1.0"
EXT_ENDCORD_VERSION = "1.4.2"
EXT_DESCRIPTION = "View animated custom emoji as GIFs"
EXT_SOURCE = "https://git.silvertke.net/SilverTke/endcord-aemoji"
EXT_COMMAND_ASSIST = ("view_aemoji - View animated emoji", "view_aemoji")
EXT_COMMAND_ASSIST = (("view_aemoji - View animated emoji", "view_aemoji"),)
EMOJI_RE = re.compile("^<:(.+):(\d+)>$")
@ -23,15 +23,19 @@ class Extension:
def __init__(self, app):
self.app: Endcord = app
def on_execute_command(self, command_text: str, chat_sel: int, tree_sel: int):
def on_execute_command(
self, command_text: str, chat_sel: int, tree_sel: int
) -> bool:
if command_text.startswith("view_aemoji"):
try:
emoji = command_text.split(" ")[1]
except IndexError:
self.app.update_extra_line("Emoji argument not given")
return
return True
emoji_url = get_emoji_url(emoji)
if emoji_url is None:
self.app.update_extra_line("Invalid emoji")
return
return True
self.app.download_file(emoji_url, open_media=True)
return True
return False