benjick / meteor-telegram-bot

Telegram bot plugin for Meteor
24 stars 15 forks source link

Possibility to add sendDocument example? #1

Closed defunctl closed 8 years ago

defunctl commented 9 years ago

This would be extremely helpful in terms of showing how you would post a new file to the telegram API.

benjick commented 9 years ago

How do you have the file now? This is an example with fs. I have no chance to test this now but this since I'm not where I have access to Meteor etc.

var fs = Npm.require('fs');
TelegramBot.addListener('senddoc', function(command, username, original) {
    fs.readFile('/etc/hosts', 'utf8', function (err,data) {
        if (err) {
            console.log(err);
            return;
        }
        TelegramBot.method('sendDocument', {
            chat_id: original.chat.id,
            document: data,
        })
    });

})
benjick commented 8 years ago

Assuming this worked