yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.17k stars 1.5k forks source link

DeprecationWarning: In the future, content-type of files you send will default to "application/octet-stream" #1071

Closed theraw closed 9 months ago

theraw commented 1 year ago

code's

      const fileOptions = {
        filename: '1.txt',
        contentType: 'text/plain'
      };
      bot.sendDocument(chatid, file, {}, fileOptions);

gives the Deprecation Warning

(node:355190) [node-telegram-bot-api] DeprecationWarning: In the future, content-type of files you send will default to "application/octet-stream". See https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files for more information on how sending files has been improved and on how to disable this deprecation message altogether.
(Use `node --trace-deprecation ...` to show where the warning was created)

trying to set contentType: 'application/octet-stream' the same Deprecation Warning, your link https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files does not give any details about sendDocument for improved or how to disable this deprecation message?

am i using sendDocument/contentType wrongly or what? i understand that there are ways that you can disable node deprecation warnings but that's not an option for me. thank you

Emanxu commented 9 months ago

you need to enable environment variable NTBA_FIX_350 and try again process.env.NTBA_FIX_350 = true;