yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.35k stars 1.52k forks source link

[Bug] bot.downloadFile not combine path correctly with LocalTgBotApiServer used #1047

Open b5414 opened 1 year ago

b5414 commented 1 year ago

I want to get video file to my С:\PROJECT\download folder, i.e. С:\PROJECT\download\video.mp4

Issue with: bot.downloadFile()

Expected Behavior

bot.downloadFile(msg.video.file_id, './download/'); // Expected filePath here

ps I picked up './download/' from this issue

Actual Behavior

response = ENOENT: no such file or directory, open 'С:\PROJECT\download\С:\PROJECT\src\localBotApiServer\data\123123~AAAAAA\videos\file_1.mp4'

С:\PROJECT\src\localBotApiServer has telegram-bot-api.exe inside

Seems so "LocalTgBotApi" server respond with Full file path, but this lib combine and think this is just a simple file name

Steps to reproduce the Behavior

  1. Build "LocalTgBotApi" (Windows)
  2. Bake a full code (import libs and etc) with important part of the code below
  3. Start "LocalTgBotApi" by cmd telegram-bot-api.exe --local --api-id=ID --api-hash=HASH --http-stat-port 8090
  4. Make sure all fine by using bot.getMe()
  5. Start node bot
  6. Send 1 video in bot's chat
  7. Check response
const token = 'tokentoken';
const baseApiUrl = 'http://0.0.0.0:8081'; // cmd > ipconfig
const bot = new TelegramBot(token, {polling: true, baseApiUrl});

bot.on('message', async(msg)=>{
    const response = await bot.downloadFile(msg?.video?.file_id, './download/').catch((e)=>e.message);
    console.log('response', response);
});

Actually

bot.downloadFile(msg?.video?.file_id, '')

is working, but it saving files in LocalTgBotApi's folder: С:\PROJECT\src\localBotApiServer\data\123123~AAAAAA\videos\file_1.mp4

ps I sure that:

ps It seemed to me that the file is full loaded after some time after a good response returned..