Add fanciness: forms
See original GitHub issueForms can allow a more complex chain of queries between the bot and the user, without requiring the programmer to define explicitly the interactions between them.
The original inspiration for this feature was from https://dev.albertocoscia.me/nodeogram/quickstart.html#forms.
While it is possible to implement this entirely in tgfancy, I believe it will be better to have a more generic solution, i.e. a form engine, that can be used across multiple platforms, other than just Telegram, using "adapters’.
A favorable API can be adapted from Inquirer.js.
The expected code would look something like: (this is hypothetical!)
// npm-installed module
const FormSet = require('forms');
const TgformAdapter = require('forms-telegram');
const ConsoleformAdapter = require('forms-console');
// module variables
const formset = new FormSet();
const tgformAdapter = new TgformAdapter(bot);
const consoleformAdapter = new ConsoleformAdapter();
// adding the adapters
formset.addAdapter('telegram', tgformAdapter);
formset.addAdapter('console', consoleformAdapter);
// adding a form, used for building a user's profile i.e name, age, etc.
formset.addForm('profile', [
// name
{
name: "name",
message: "What is your name?",
validate(answer) { /* ... validate ... */ },
when(answers) { /* ... do we ask ... */ },
},
// ... more questions ...
]);
// let's ask for the details from the user, on the command '/start'
bot.onText(/^\/start$/, function(msg, match) {
formset.send('profile', 'telegram', function(error, answers) {
// ... handle error ...
// 'answers' is an object with the user's answers
console.log(answers);
});
});
tgfancy would offer a formset by default, for more implicit solutions!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Increasing overall fanciness - Dragon Quest Builders 2
Making all the walls and floors out of gold brick/tile is the easiest way to get max fanciness. This. Just make a bunch...
Read more >Fanciness - definition of fanciness by The Free Dictionary
1. The power of the mind to form images: fantasy, imagination, imaginativeness. · 2. An illusory mental image: · 3. An impulsive, often...
Read more >Mini Guide Dragon Quest Builders 2: Scarlet Sands Red ...
Optional Increase overall Fanciness: To increase the overall fanciness of a room the wall and floor are taken into account so using Silver...
Read more >What is another word for fanciness? - WordHippo
Find 437 synonyms for fanciness and other similar words that you can use instead based on 2 separate contexts from our thesaurus.
Read more >Button Switches with Checkboxes and CSS3 Fanciness
Then, the label, which is where we'll add all the styling to. First of all, we set it to block and make it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Possibly use async await.
@FaRzad-845 It’s just at theory. Work is in progress to make it a reality! 😃