yagop / node-telegram-bot-api

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

Using String in sendDocument #1042

Open lezioul opened 1 year ago

lezioul commented 1 year ago

hi, i'm trying to use sendDocument() with a text content :

const fileOptions = {
    filename: 'file.txt',
    contentType: 'text/plain'
};

const options = {
    caption: 'myCaption'
};

var r = bot.sendDocument(chatId,"tytxtxttxtx",options,fileOptions);
r.then(function successHandler(result) {
    console.log("sendDoc resultg: " + result);
}, function failureHandler(error) {
    console.log("error sendDoc: " + error);
});

But i always have errors like theses (deping on String size i pass to the function) :

janv. 11 23:15:32 ns386759 node[19860]: error sendDoc: Error: ETELEGRAM: 400 Bad Request: wrong remote file identifier specified: can't unserialize it. Wrong last symbol

janv. 11 23:15:48 ns386759 node[19860]: error sendDoc: Error: ETELEGRAM: 400 Bad Request: wrong remote file identifier specified: Wrong padding in the string

i've trying reading a local text file, as seen in the example section, in order to provide a proper buffer or stream to sendDocument but i have the same issue. Any ideas?

Best Regards