mast / telegram-bot-api

First Telegram Bot API node.js library
http://mast.github.io/telegram-bot-api/
MIT License
246 stars 64 forks source link

sendVideo : Bad request #76

Closed Biskwit closed 3 years ago

Biskwit commented 3 years ago

Hi, trying to send a video using API, but i get an error 400 (or "host invalid") since i updated from 1.3 -> 2.0.0

code :

let api = new telegram({
        token: '****************************',
        updates: { 
            enabled: true
        }
});

const mp = new telegram.GetUpdateMessageProvider()

api.setMessageProvider(mp)
api.start()
.then(() => {
    console.log('API is started')
    api.sendVideo({
        chat_id: **********,
        video: "./temp/wdZGjR9m0D.mp4"
    }).then(() => { 
        //Fs.unlinkSync(output)
    })
})
.catch(console.err)

result :

{
  code: 400,
  description: 'Bad Request: URL host is empty',
  body: {
    ok: false,
    error_code: 400,
    description: 'Bad Request: URL host is empty'
  }
}
mast commented 3 years ago

After 2.0 you have to pass readableStream object instead of file name. Ex: video: fs.createReadStream("./temp/wdZGjR9m0D.mp4")

Please let me know if it helped.

Biskwit commented 3 years ago

After 2.0 you have to pass readableStream object instead of file name. Ex: video: fs.createReadStream("./temp/wdZGjR9m0D.mp4")

Please let me know if it helped.

It work, thank you 👍