depoio / node-telegram-bot

Client wrapper for Telegram Bot API (Under heavy development)
MIT License
136 stars 30 forks source link

node-telegram-bot

Join the chat at https://gitter.im/depoio/node-telegram-bot build statusdependenciesnode versionnpm version

Changelog

Documentation

Documentation is built using jsdoc with DocStrap. More to come (including examples)! Documentation Link

Sending files (including photo, audio, document, video and sticker)

Now only require filepath,


bot.sendPhoto({
  chat_id: USER_ID,
  caption: 'Telegram Logo',
  files: {
    photo: './examples/logo.png'
  }
}, function (err, msg) {
  console.log(err);
  console.log(msg);
});

Previously,


bot.sendPhoto({
  chat_id: USER_ID,
  caption: 'Telegram Logo',
  files: {
    photo: {
      filename: './examples/logo.png',
      stream: fs.createReadStream('./examples/logo.png')
    }
  }
}, function (err, msg) {
  console.log(err);
  console.log(msg);
});

Here's an example:


var Bot = require('node-telegram-bot');

var bot = new Bot({
  token: 'TOKEN HERE'
})
.on('message', function (message) {
  console.log(message);
})
.start();

How to use Botan.io analytics:


var bot = new Bot({
  token: 'Telegram token'
})
.enableAnalytics('Botan.io token')
.on('message', function (message) {
  console.log(message);
})
.start();

Credits

Sample sound