Deprecated: A simple API to create and control Telegram bots
Go to file
Mahdi Dibaiee cf6c79e1e3 rename
2015-06-27 01:16:22 +04:30
lib initial commit 2015-06-26 21:50:54 +04:30
.gitignore initial commit 2015-06-26 21:50:54 +04:30
index.js initial commit 2015-06-26 21:50:54 +04:30
LICENSE Initial commit 2015-06-26 03:04:01 +04:30
package.json rename 2015-06-27 01:16:22 +04:30
README.md initial commit 2015-06-26 21:50:54 +04:30

Telegram Bots

Control Telegram bots easily.

npm install telegram-bots

Example

let Bot = require('telegram-bots');

let smartBot = new Bot({
  token: 'YOUR_TOKEN'
});

// update is an Update object as described in Telegram Bots API documentation
smartBot.on('Hi', update => {
  const message = update.message,
        id = message.chat.id;

  const question = 'How should I greet you?',
        answers = ['Hi', 'Hello, Sir', 'Yo bro'];

  smartBot.askQuestion(id, question, answers)
  .then(answer => {
    smartBot.message(id, `Your answer: ${answer}`);
  }, () => {
    smartBot.message(id, 'Invalid answer');
  });
});

smartBot.command('test', update => {
  const message = update.message;
  const id = message.chat.id;

  smartBot.message(id, 'Test command');
});

smartBot.command('start', update => {
  smartBot.message(update.message.chat.id, 'Hello!');
});

This will result in: