-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6088675
commit 16dba0d
Showing
5 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { form_processor, lottus, redirect } from "../index.js"; | ||
|
||
let input = lottus(); | ||
|
||
input.info("main", async (_, res) => { | ||
res.body = "Please tell me your name"; | ||
res.addInput({name: "name", next: "profession"}); | ||
|
||
return res; | ||
}); | ||
|
||
input.form("main", form_processor); | ||
|
||
input.info("profession", async (_, res) => { | ||
res.addInput({name: "profession", next: "show_details"}); | ||
|
||
res.body = "Please tell me your profession"; | ||
|
||
return res; | ||
}); | ||
|
||
input.form("profession", form_processor); | ||
|
||
input.info("show_details", async (req, res) => { | ||
for(const key in req.parameters){ | ||
res.body += "[" + key + ":" + req.parameters[key] + "]"; | ||
} | ||
|
||
return res; | ||
}); | ||
|
||
let message = await input.process({prompt: "hello"}); | ||
console.log(message); | ||
console.log("--------------------------------------------------"); | ||
|
||
message = await input.process({prompt: "Ben Chambule", parameters: message.parameters}, message); | ||
console.log(message); | ||
console.log("--------------------------------------------------"); | ||
|
||
message = await input.process({prompt: "Developer", parameters: message.parameters}, message); | ||
console.log(message); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { form_processor, format_message, lottus } from "../index.js"; | ||
|
||
let options = lottus(); | ||
|
||
options.info("main", async (_, msg) => { | ||
msg.body = "Please select an option"; | ||
|
||
msg.addAutoOption({label: "Name", next:"name"}); | ||
msg.addAutoOption({label: "Profession", next:"profession"}); | ||
|
||
return msg; | ||
}); | ||
|
||
options.form("main", form_processor); | ||
|
||
options.info("name", async (_, msg) => { | ||
msg.body = "You selected 1 - Name"; | ||
msg.addOption({label: "Back", key: 0, next: "main"}); | ||
|
||
return msg; | ||
}); | ||
|
||
options.form("name", form_processor); | ||
|
||
options.info("profession", async (_, msg) => { | ||
msg.body = "You selected 2 - Profession"; | ||
msg.addOption({label: "Back", key: 0, next: "main"}); | ||
|
||
return msg; | ||
}); | ||
|
||
options.form("profession", form_processor); | ||
|
||
let message = await options.process({prompt:"hello"}); | ||
console.log(format_message(message)); | ||
|
||
message = await options.process({prompt:"1"}, message); | ||
console.log(format_message(message)); | ||
|
||
message = await options.process({prompt:"0"}, message); | ||
console.log(format_message(message)); | ||
|
||
message = await options.process({prompt:"2"}, message); | ||
console.log(format_message(message)); | ||
|
||
message = await options.process({prompt:"0"}, message); | ||
console.log(format_message(message)); |
This file contains 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