Skip to content

Instantly share code, notes, and snippets.

@mdibaiee
Created June 26, 2015 16:46
Show Gist options
  • Select an option

  • Save mdibaiee/2fd2cd8b20aba66da82b to your computer and use it in GitHub Desktop.

Select an option

Save mdibaiee/2fd2cd8b20aba66da82b to your computer and use it in GitHub Desktop.
telegram-bots Example
var Bot = require('./index');
var myBot = new Bot({token: '121143906:AAE6pcpBoARNZZjr3fUpvKuLInJ5Eee5Ajk'});
myBot.start();
myBot.on('Hi', function(update) {
const message = update.message;
const id = message.chat.id;
const question = 'How should I greet you?',
answers = ['Hi', 'Hello, Sir', 'Yo bro'];
myBot.askQuestion(id, question, answers)
.then(answer => {
myBot.message(id, 'Your answer: ' + answer);
}, () => {
myBot.message(id, 'Invalid answer');
});
});
myBot.command('test', function(update) {
const message = update.message;
const id = message.chat.id;
myBot.message(id, 'Test command');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment