add full telegram sticker link support

This commit is contained in:
Kentai Radiquum 2024-12-23 15:38:21 +05:00
parent 75419f5906
commit b9461d75be
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
2 changed files with 6 additions and 2 deletions

View file

@ -32,7 +32,7 @@ class Command:
"I am the bot that imports stickers from Telegram and upload them to Matrix rooms\n\n" "I am the bot that imports stickers from Telegram and upload them to Matrix rooms\n\n"
"List of commands:\n" "List of commands:\n"
"help - Show this help message.\n" "help - Show this help message.\n"
"import <pack_name> [import_name] - Use this to import Telegram stickers from given link. import_name is pack_name if not provided" "import <url|pack_name> [import_name] - Use this to import Telegram stickers from given link. import_name is pack_name if not provided"
) )
await send_text_to_room(self.client, self.room.room_id, text) await send_text_to_room(self.client, self.room.room_id, text)

View file

@ -72,8 +72,12 @@ class TelegramExporter:
async def get_stickerset(self, pack_name: str) -> list[Sticker]: async def get_stickerset(self, pack_name: str) -> list[Sticker]:
result: List[Sticker] = list() result: List[Sticker] = list()
short_name = pack_name
if short_name.startswith('http'):
short_name = pack_name.split("/")[-1]
try: try:
sticker_set = await self.client(GetStickerSetRequest(InputStickerSetShortName(short_name=pack_name), hash=0)) sticker_set = await self.client(GetStickerSetRequest(InputStickerSetShortName(short_name=short_name), hash=0))
except StickersetInvalidError: except StickersetInvalidError:
return result # return empty on fail return result # return empty on fail