This commit is contained in:
2023-08-06 15:30:02 +02:00
parent af0cbf66f4
commit d95f679f52
2 changed files with 5 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ class UploadBackend(enum.StrEnum):
class Data(TypedDict): class Data(TypedDict):
chat_id: str | int chat_id: int
message_id: int message_id: int

View File

@@ -1,4 +1,4 @@
from typing import AsyncIterator, Optional, Union from typing import AsyncIterator, Optional
import telethon.client import telethon.client
import telethon.errors import telethon.errors
@@ -9,9 +9,7 @@ from core.config import env_config
class BaseStorage: class BaseStorage:
def __init__( def __init__(self, channel_id: int, app_id: int, api_hash: str, session: str):
self, channel_id: Union[str, int], app_id: int, api_hash: str, session: str
):
self.channel_id = channel_id self.channel_id = channel_id
self.client = telethon.client.TelegramClient(session, app_id, api_hash) self.client = telethon.client.TelegramClient(session, app_id, api_hash)
@@ -26,7 +24,7 @@ class BaseStorage:
file: telethon.hints.FileLike, file: telethon.hints.FileLike,
file_size: int, file_size: int,
caption: Optional[str] = None, caption: Optional[str] = None,
) -> Optional[tuple[Union[str, int], int]]: ) -> Optional[tuple[int, int]]:
try: try:
uploaded_file = await self.client.upload_file(file, file_size=file_size) uploaded_file = await self.client.upload_file(file, file_size=file_size)
@@ -87,7 +85,7 @@ class UserStorage(BaseStorage):
class BotStorage(BaseStorage): class BotStorage(BaseStorage):
def __init__( def __init__(
self, self,
channel_id: Union[str, int], channel_id: int,
app_id: int, app_id: int,
api_hash: str, api_hash: str,
session: str, session: str,