Bump to v1.1

This commit is contained in:
Dr.Caduceus
2023-11-06 12:48:13 +05:30
committed by GitHub
parent 786a153493
commit 28e1e52602

View File

@@ -1,6 +1,6 @@
from quart import Blueprint, Response, request, render_template, redirect
from .error import abort
from bot import version, TelegramBot
from bot import TelegramBot
from bot.config import Telegram, Server
from bot.modules.telegram import get_message, get_file_properties
@@ -18,16 +18,19 @@ async def transmit_file(file_id):
if code != file.caption:
abort(403)
file_name, mime_type = await get_file_properties(file)
file_name, file_size, mime_type = await get_file_properties(file)
headers = {
'Content-Type': mime_type,
'Content-Disposition': f'attachment; filename="{file_name}"'
'Content-Disposition': f'attachment; filename="{file_name}"',
'Content-Length': file_size
}
file_stream = TelegramBot.stream_media(file)
return Response(file_stream, headers=headers)
@bp.route('/stream/<int:file_id>')
async def stream_file(file_id):
code = request.args.get('code') or abort(401)
@@ -38,4 +41,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}')