-
Notifications
You must be signed in to change notification settings - Fork 21
Type: Question
Mahdi Dibaiee edited this page Jul 3, 2015
·
1 revision
Asks a question, and validates the answer.
The way it works under the hood:
- Sends a message with a keyboard taken from answers
- Waits for an answer from user, if in group, expects a reply
- Validates the answer, resolves if it's valid, else rejects
Here is the chainable method equivalent of each option:
- answers => An array of arrays of strings, same as Keyboard keys option
- to => chat_id
- text => text
- preview => disable_web_page_preview (The option is inversed, e.g. preview(false) will set the option to true, therefore disabling previews)
- reply => reply_to_message_id
const q = new Question()
.text('What type of music do you prefer?')
.answers([['Rock'], ['Pop'], ['Hip-Hop']])
.to(chat.id);
bot.send(q).then(message => {
console.log('Valid Answer:', message.text);
}, message => {
console.log('Invalid:', message.text);
});