mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-06 15:14:52 +00:00
Pyrofork: Move duplicated codes to separate method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
41e13454e7
commit
f2b6182584
1 changed files with 21 additions and 26 deletions
|
|
@ -28,6 +28,25 @@ class SendStory:
|
||||||
def _split(self, message, entities, *args, **kwargs):
|
def _split(self, message, entities, *args, **kwargs):
|
||||||
return message, entities
|
return message, entities
|
||||||
|
|
||||||
|
async def _upload_video(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
file_name: str,
|
||||||
|
video: Union[str, BinaryIO]
|
||||||
|
):
|
||||||
|
file = await self.save_file(video)
|
||||||
|
return raw.types.InputMediaUploadedDocument(
|
||||||
|
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
|
||||||
|
file=file,
|
||||||
|
attributes=[
|
||||||
|
raw.types.DocumentAttributeVideo(
|
||||||
|
supports_streaming=True,
|
||||||
|
duration=0,
|
||||||
|
w=0,
|
||||||
|
h=0
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
async def send_story(
|
async def send_story(
|
||||||
self: "pyrogram.Client",
|
self: "pyrogram.Client",
|
||||||
chat_id: Union[int,str] = None,
|
chat_id: Union[int,str] = None,
|
||||||
|
|
@ -185,33 +204,9 @@ class SendStory:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
video = await self.download_media(video, in_memory=True)
|
video = await self.download_media(video, in_memory=True)
|
||||||
file = await self.save_file(video)
|
media = await self._upload_video(file_name,video)
|
||||||
media = raw.types.InputMediaUploadedDocument(
|
|
||||||
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
|
|
||||||
file=file,
|
|
||||||
attributes=[
|
|
||||||
raw.types.DocumentAttributeVideo(
|
|
||||||
supports_streaming=True,
|
|
||||||
duration=0,
|
|
||||||
w=0,
|
|
||||||
h=0
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
file = await self.save_file(video)
|
media = await self._upload_video(file_name,video)
|
||||||
media = raw.types.InputMediaUploadedDocument(
|
|
||||||
mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
|
|
||||||
file=file,
|
|
||||||
attributes=[
|
|
||||||
raw.types.DocumentAttributeVideo(
|
|
||||||
supports_streaming=True,
|
|
||||||
duration=0,
|
|
||||||
w=0,
|
|
||||||
h=0
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
if forward_from_chat_id is None:
|
if forward_from_chat_id is None:
|
||||||
raise ValueError("You need to pass one of the following parameter photo/video/forward_from_chat_id!")
|
raise ValueError("You need to pass one of the following parameter photo/video/forward_from_chat_id!")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue