Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
721 stars 143 forks source link

How to recover results from forms? #96

Closed Charlyo closed 8 years ago

Charlyo commented 8 years ago

I understand that the console.log after the .runForm gives the input of the user response of the forms. However, no result is displayed...

kamikazechaser commented 8 years ago

Save it to a database of your choice.

Charlyo commented 8 years ago

Following the example: const form = { name: { q: 'Send me your name', error: 'sorry, wrong input', validator: (message, callback) => { if(message.text) { callback(true, message.text) //you must pass the result also return }

        callback(false)
    }
},
age: {
    q: 'Send me your age',
    error: 'sorry, wrong input',
    validator: (message, callback) => {
        if(message.text && IsNumeric(message.text)) {
            callback(true, toInt(message.text))
            return
        }

        callback(false)
    }
}

}

$.runForm(form, (result) => { // * console.log(result) })

This last console.log, should show the user input in each question of the form. However, * never executes.

edakhmetgareev commented 8 years ago

I think the problem in the validator function. IsNumber and toInt functions are not defined in js by default.