I can't figure out how to send large files. I installed a local server and connected to it. The bot code is attached below. TBA server startup parameters:
telegram-bot-api --http-port 8081 --dir=/var/lib/telegram-bot-api --temp-dir=/tmp/telegram-bot-api --username=telegram-bot-api --groupname=telegram-bot-api --local import loggingfrom telegram import Updatefrom telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypesAPI_TOKEN = API_TOKENADMIN_ID = ADMIN_IDSERVER_URL = SERVER_URLasync def start(update: Update, context): await update.message.reply_text("test")async def handle_file(update: Update, context): await send_file_srv(context)async def send_file_srv(application: Application) -> None: await application.bot.send_document(chat_id=ADMIN_ID, document=open('./test.zip', 'rb'))def main(): app = Application.builder().token(API_TOKEN).base_url(SERVER_URL).local_mode(True).build() app.add_handler(CommandHandler("start", start)) app.add_handler(CommandHandler("send", handle_file)) app.run_polling()if __name__ == '__main__': main()
I change the ./test.zip file for testing If it is within (plus or minus) 100 megabytes. Then it loads normally, without errors. If the size is more than 100, then errors of this type begin:
telegram.error.TimedOut: Timed out But the file still loads. If the file size is about 300 or more, then the same errors are displayed several times, then they stop and the file does not load. Please clarify, give an example of a bot that correctly sends large files. |