mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7846873b9c
|
||
|
|
6d06e28598
|
||
|
|
4083b09093
|
@@ -4,8 +4,10 @@ from aiohttp import ClientSession
|
||||
from telegram import (
|
||||
InlineQueryResultPhoto,
|
||||
InlineQueryResultVideo,
|
||||
InlineQueryResultMpeg4Gif,
|
||||
InputMediaPhoto,
|
||||
InputMediaVideo
|
||||
InputMediaVideo,
|
||||
InputMediaAnimation
|
||||
)
|
||||
|
||||
from common import x_url_regex, x_media_regex, x_tco_regex, logger
|
||||
@@ -48,6 +50,10 @@ class TweetMedia:
|
||||
return f"{twimg_url}{self._uri}?format=jpg&name=4096x4096"
|
||||
case "video":
|
||||
return self._url
|
||||
case "gif":
|
||||
return self._url
|
||||
case _:
|
||||
return self._url
|
||||
|
||||
@property
|
||||
def thumb(self) -> str:
|
||||
@@ -56,6 +62,10 @@ class TweetMedia:
|
||||
return f"{twimg_url}{self._uri}?format=jpg&name=thumb"
|
||||
case "video":
|
||||
return self._thumb
|
||||
case "gif":
|
||||
return self._thumb
|
||||
case _:
|
||||
return self._thumb
|
||||
|
||||
@property
|
||||
def type(self) -> str:
|
||||
@@ -186,8 +196,6 @@ class TGTweet(Tweet):
|
||||
id=str(i),
|
||||
photo_url=tweet_media.url,
|
||||
thumbnail_url=tweet_media.thumb,
|
||||
title=self.url,
|
||||
description=self.text,
|
||||
caption=self.message_text if not i else None
|
||||
)
|
||||
elif tweet_media.type == "video":
|
||||
@@ -196,8 +204,14 @@ class TGTweet(Tweet):
|
||||
video_url=tweet_media.url,
|
||||
mime_type="video/mp4",
|
||||
thumbnail_url=tweet_media.thumb,
|
||||
title=self.url,
|
||||
description=self.text,
|
||||
title=self.text,
|
||||
caption=self.message_text if not i else None
|
||||
)
|
||||
elif tweet_media.type == "gif":
|
||||
yield InlineQueryResultMpeg4Gif(
|
||||
id=str(i),
|
||||
mpeg4_url=tweet_media.url,
|
||||
thumbnail_url=tweet_media.thumb,
|
||||
caption=self.message_text if not i else None
|
||||
)
|
||||
|
||||
@@ -216,3 +230,9 @@ class TGTweet(Tweet):
|
||||
has_spoiler=self.sensitive,
|
||||
thumbnail=tweet_media.thumb
|
||||
)
|
||||
elif tweet_media.type == "gif":
|
||||
yield InputMediaAnimation(
|
||||
media=tweet_media.url,
|
||||
has_spoiler=self.sensitive,
|
||||
thumbnail=tweet_media.thumb
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user