hopefully fix sticker sending
This commit is contained in:
parent
fc4a1423f2
commit
adc324ad45
1 changed files with 12 additions and 9 deletions
|
@ -1,8 +1,8 @@
|
||||||
diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py
|
diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py
|
||||||
index 3b6a81e..0f5aed4 100644
|
index 3b6a81e..c6277a7 100644
|
||||||
--- a/mautrix_telegram/portal.py
|
--- a/mautrix_telegram/portal.py
|
||||||
+++ b/mautrix_telegram/portal.py
|
+++ b/mautrix_telegram/portal.py
|
||||||
@@ -1626,6 +1626,35 @@ class Portal(DBPortal, BasePortal):
|
@@ -1626,6 +1626,36 @@ class Portal(DBPortal, BasePortal):
|
||||||
msgtype=content.msgtype,
|
msgtype=content.msgtype,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,34 +11,35 @@ index 3b6a81e..0f5aed4 100644
|
||||||
+ client,
|
+ client,
|
||||||
+ metadata
|
+ metadata
|
||||||
+ ):
|
+ ):
|
||||||
+ sticker_set_id = metadata["pack"]["id"]
|
+ sticker_set_id = int(metadata["pack"]["id"])
|
||||||
+ from telethon.tl.functions.messages import GetAllStickersRequest
|
+ from telethon.tl.functions.messages import GetAllStickersRequest
|
||||||
+ sticker_sets = await client(GetAllStickersRequest(0))
|
+ sticker_sets = await client(GetAllStickersRequest(0))
|
||||||
+ from telethon.tl.functions.messages import GetStickerSetRequest
|
+ from telethon.tl.functions.messages import GetStickerSetRequest
|
||||||
+ from telethon.tl.types import InputStickerSetID
|
+ from telethon.tl.types import InputStickerSetID
|
||||||
+ found_sticker_set = None
|
+ found_sticker_set = None
|
||||||
+ for sticker_set in sticker_sets.sets:
|
+ for sticker_set in sticker_sets.sets:
|
||||||
+ if sticker_set.set.id == sticker_set_id:
|
+ if sticker_set.id == sticker_set_id:
|
||||||
+ found_sticker_set = sticker_set
|
+ found_sticker_set = sticker_set
|
||||||
+ break
|
+ break
|
||||||
+ if not found_sticker_set:
|
+ if not found_sticker_set:
|
||||||
+ return None
|
+ return None
|
||||||
+
|
+
|
||||||
+ stickers = await client(GetStickerSetRequest(
|
+ stickers = await client(GetStickerSetRequest(
|
||||||
|
+ hash = 0,
|
||||||
+ stickerset=InputStickerSetID(
|
+ stickerset=InputStickerSetID(
|
||||||
+ id=found_sticker_set.id, access_hash=found_sticker_set.access_hash
|
+ id=found_sticker_set.id, access_hash=found_sticker_set.access_hash
|
||||||
+ )
|
+ )
|
||||||
+ ))
|
+ ))
|
||||||
+
|
+
|
||||||
+ for sticker in stickers.documents:
|
+ for sticker in stickers.documents:
|
||||||
+ if sticker.file_id == metadata["id"]:
|
+ if sticker.id == int(metadata["id"]):
|
||||||
+ return sticker
|
+ return sticker
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
async def _handle_matrix_file(
|
async def _handle_matrix_file(
|
||||||
self,
|
self,
|
||||||
sender: u.User,
|
sender: u.User,
|
||||||
@@ -1646,6 +1675,7 @@ class Portal(DBPortal, BasePortal):
|
@@ -1646,6 +1676,7 @@ class Portal(DBPortal, BasePortal):
|
||||||
w = h = None
|
w = h = None
|
||||||
max_image_size = self.config["bridge.image_as_file_size"] * 1000**2
|
max_image_size = self.config["bridge.image_as_file_size"] * 1000**2
|
||||||
max_image_pixels = self.config["bridge.image_as_file_pixels"]
|
max_image_pixels = self.config["bridge.image_as_file_pixels"]
|
||||||
|
@ -46,7 +47,7 @@ index 3b6a81e..0f5aed4 100644
|
||||||
|
|
||||||
if self.config["bridge.parallel_file_transfer"] and content.url:
|
if self.config["bridge.parallel_file_transfer"] and content.url:
|
||||||
file_handle, file_size = await util.parallel_transfer_to_telegram(
|
file_handle, file_size = await util.parallel_transfer_to_telegram(
|
||||||
@@ -1666,7 +1696,14 @@ class Portal(DBPortal, BasePortal):
|
@@ -1666,7 +1697,14 @@ class Portal(DBPortal, BasePortal):
|
||||||
file = await self.main_intent.download_media(content.url)
|
file = await self.main_intent.download_media(content.url)
|
||||||
|
|
||||||
if content.msgtype == MessageType.STICKER:
|
if content.msgtype == MessageType.STICKER:
|
||||||
|
@ -62,12 +63,14 @@ index 3b6a81e..0f5aed4 100644
|
||||||
mime, file, w, h = util.convert_image(
|
mime, file, w, h = util.convert_image(
|
||||||
file, source_mime=mime, target_type="webp"
|
file, source_mime=mime, target_type="webp"
|
||||||
)
|
)
|
||||||
@@ -1708,6 +1745,8 @@ class Portal(DBPortal, BasePortal):
|
@@ -1708,7 +1746,9 @@ class Portal(DBPortal, BasePortal):
|
||||||
if "fi.mau.telegram.force_document" in content:
|
if "fi.mau.telegram.force_document" in content:
|
||||||
force_document = bool(content["fi.mau.telegram.force_document"])
|
force_document = bool(content["fi.mau.telegram.force_document"])
|
||||||
|
|
||||||
|
- if (mime == "image/png" or mime == "image/jpeg") and not force_document:
|
||||||
+ if media is not None:
|
+ if media is not None:
|
||||||
+ pass
|
+ pass
|
||||||
if (mime == "image/png" or mime == "image/jpeg") and not force_document:
|
+ elif (mime == "image/png" or mime == "image/jpeg") and not force_document:
|
||||||
media = InputMediaUploadedPhoto(file_handle)
|
media = InputMediaUploadedPhoto(file_handle)
|
||||||
else:
|
else:
|
||||||
|
media = InputMediaUploadedDocument(
|
||||||
|
|
Reference in a new issue