Spaces:
Configuration error
Configuration error
| from telethon import TelegramClient | |
| from aiohttp.web import Request | |
| class Sanity: | |
| client: TelegramClient | |
| media = None | |
| chat_id: int | |
| file_id: int | |
| req: Request | |
| limit: int | |
| offset: int | |
| async def file_exists(self): | |
| try: | |
| self.media = await self.client.get_messages( | |
| entity=self.chat_id, ids=self.file_id | |
| ) | |
| return self.media | |
| except Exception as e: | |
| pass | |
| def check_ranges(self): | |
| offset = self.req.http_range.start or 0 | |
| limit = self.req.http_range.stop or self.media.file.size | |
| self.offset = offset | |
| self.limit = limit | |
| if (limit > self.media.file.size) or (offset < 0) or (limit < offset): | |
| return False | |
| else: | |
| return True | |