diff --git a/bot/__init__.py b/bot/__init__.py index 44289e0..da55106 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -5,7 +5,7 @@ from .config import Telegram, LOGGER_CONFIG_JSON dictConfig(LOGGER_CONFIG_JSON) -version = 1.1 +version = 1.0 logger = getLogger('bot') TelegramBot = Client( @@ -16,4 +16,4 @@ TelegramBot = Client( plugins={"root": "bot/plugins"}, workers = Telegram.BOT_WORKERS, max_concurrent_transmissions=1000 -) +) \ No newline at end of file diff --git a/bot/modules/telegram.py b/bot/modules/telegram.py index 0181351..fe2506d 100644 --- a/bot/modules/telegram.py +++ b/bot/modules/telegram.py @@ -39,7 +39,6 @@ async def get_file_properties(msg: Message): if not media: abort(400, 'Unknown file type.') file_name = getattr(media, 'file_name', None) - file_size = getattr(media, 'file_size', 0) if not file_name: file_format = { @@ -54,4 +53,4 @@ async def get_file_properties(msg: Message): mime_type = guess_type(file_name)[0] or 'application/octet-stream' - return file_name, file_size, mime_type + return file_name, mime_type \ No newline at end of file diff --git a/bot/server/main.py b/bot/server/main.py index 1fca5f4..e715347 100644 --- a/bot/server/main.py +++ b/bot/server/main.py @@ -1,6 +1,6 @@ from quart import Blueprint, Response, request, render_template, redirect from .error import abort -from bot import TelegramBot +from bot import version, TelegramBot from bot.config import Telegram, Server from bot.modules.telegram import get_message, get_file_properties @@ -18,19 +18,16 @@ async def transmit_file(file_id): if code != file.caption: abort(403) - file_name, file_size, mime_type = await get_file_properties(file) - + file_name, mime_type = await get_file_properties(file) headers = { 'Content-Type': mime_type, - 'Content-Disposition': f'attachment; filename="{file_name}"', - 'Content-Length': file_size + 'Content-Disposition': f'attachment; filename="{file_name}"' } file_stream = TelegramBot.stream_media(file) return Response(file_stream, headers=headers) - @bp.route('/stream/') async def stream_file(file_id): code = request.args.get('code') or abort(401) @@ -41,4 +38,4 @@ async def stream_file(file_id): async def file_deeplink(file_id): code = request.args.get('code') or abort(401) - return redirect(f'https://t.me/{Telegram.BOT_USERNAME}?start=file_{file_id}_{code}') + return redirect(f'https://t.me/{Telegram.BOT_USERNAME}?start=file_{file_id}_{code}') \ No newline at end of file