Skip to content

Commit

Permalink
Update compile_clips_handler.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dam2452 committed Dec 27, 2024
1 parent 1bb888e commit 33775e8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions bot/handlers/sending_videos/compile_clips_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ async def _do_handle(self, message: Message) -> None:
get_selected_clip_message(segment["video_path"], segment["start"], segment["end"], duration),
)

if await self._check_clip_duration_limit(message, total_duration):
return
if await self._check_clip_duration_limit(message.from_user.id, total_duration):
return await self.__reply_clip_duration_exceeded(message)

compiled_output = await ClipsCompiler.compile(message, selected_segments, self._logger)
await self._answer_video(message, compiled_output)
Expand Down Expand Up @@ -181,13 +181,11 @@ def __parse_single(index_str: str, segments: List[Dict[str, Union[str, float]]])
"end": segment["end"],
}

async def _check_clip_duration_limit(self, message: Message, total_duration: float) -> bool:
if await DatabaseManager.is_admin_or_moderator(message.from_user.id):
@staticmethod
async def _check_clip_duration_limit(user_id: int, total_duration: float) -> bool:
if await DatabaseManager.is_admin_or_moderator(user_id):
return False
if total_duration > settings.LIMIT_DURATION:
await self.__reply_clip_duration_exceeded(message)
return True
return False
return total_duration > settings.LIMIT_DURATION

async def __reply_no_previous_search_results(self, message: Message) -> None:
await self._answer(message, get_no_previous_search_results_message())
Expand Down

0 comments on commit 33775e8

Please sign in to comment.