Created
June 26, 2015 16:46
-
-
Save mdibaiee/2fd2cd8b20aba66da82b to your computer and use it in GitHub Desktop.
telegram-bots Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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