我应该如何从 telegram api 下载收到的文件

sid*_*aha 3 node.js telegram telegram-bot node-telegram-bot-api

我只想用nodejs 下载我的电报机器人收到的图像,但我不知道要使用的女巫方法。我正在使用node-telegram-bot-api并尝试了这段代码:

bot.on('message', (msg) => {
    const img = bot.getFileLink(msg.photo[0].file_id);

    console.log(img);
});
Run Code Online (Sandbox Code Playgroud)

这就是结果:

Promise [Object] {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined,
  _cancellationParent:
   Promise [Object] {
     _bitField: 1,
     _fulfillmentHandler0: [Function],
     _rejectionHandler0: undefined,
     _promise0: [Circular],
     _receiver0: undefined,
     _cancellationParent:
      Promise [Object] {
        _bitField: 1,
        _fulfillmentHandler0: undefined,
        _rejectionHandler0: [Function],
        _promise0: [Circular],
        _receiver0: undefined,
        _cancellationParent: [Promise],
        _branchesRemainingToCancel: 1 },
     _branchesRemainingToCancel: 1 } }
Run Code Online (Sandbox Code Playgroud)

Mic*_*uez 5

bot.on('message', async (msg) => {
    if (msg.photo && msg.photo[0]) {
        const image = await bot.getFile({ file_id: msg.photo[0].file_id });
        console.log(image);
    }
});
Run Code Online (Sandbox Code Playgroud)

https://github.com/mast/telegram-bot-api/blob/master/lib/telegram-bot.js#L1407