mirror of
https://github.com/TheCaduceus/FileStreamBot.git
synced 2026-01-15 16:33:25 -03:00
Bump to v1.1
This commit is contained in:
@@ -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}')
|
||||
|
||||
Reference in New Issue
Block a user