Skip to content

Commit

Permalink
changes: remove redirect from lottus
Browse files Browse the repository at this point in the history
  • Loading branch information
benchambule committed Aug 24, 2024
1 parent b07fa44 commit 4b3e423
Show file tree
Hide file tree
Showing 6 changed files with 448 additions and 361 deletions.
4 changes: 2 additions & 2 deletions examples/bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Lottus } from "../index.js";
import { lottus } from "../index.js";

let input = new Lottus();
let input = lottus();

input.at("main",
// info
Expand Down
10 changes: 5 additions & 5 deletions examples/inputs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Lottus } from "../index.js";
import { lottus, redirect } from "../index.js";

let input = new Lottus();
let input = lottus();

input.info("main", async (_, res) => {
res.form = {input: "name"};
Expand All @@ -14,7 +14,7 @@ input.form("main", async (req, res) => {
if(req.prompt && req.prompt.trim().length > 0){
req.parameters = {name: req.prompt};

res = await input.redirect("profession", req);
res = await redirect("profession", req);
}else {
res.body = "Name cannot be empty";
}
Expand All @@ -34,7 +34,7 @@ input.form("profession", async (req, res) => {
if(req.prompt.trim().length > 0){
req.parameters = {profession: req.prompt};

res = await input.redirect("show_details", req);
res = await redirect("show_details", req);
} else {
res.body = "Name cannot be empty"
}
Expand All @@ -46,7 +46,7 @@ input.info("show_details", async (req, res) => {
res.form = false;

for(const key in req.parameters){
res.body += "[" + key + ":" + req.parameters[key] + "]";
res.body = "[" + key + ":" + req.parameters[key] + "]";
}

return res;
Expand Down
14 changes: 7 additions & 7 deletions examples/options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Lottus } from "../index.js";
import { format_message, lottus, redirect } from "../index.js";

let options = new Lottus();
let options = new lottus();

options.info("main", async (_, msg) => {
msg.form = {input: "options"};
Expand All @@ -16,11 +16,11 @@ options.form("main", async (req, msg) => {
msg.body += "\nUnknow option";

if(req.prompt.trim() === "1"){
msg = options.redirect("name");
msg = redirect("name");
}

if(req.prompt.trim() === "2"){
msg = options.redirect("profession");
msg = redirect("profession");
}

return msg;
Expand All @@ -40,7 +40,7 @@ options.form("name", async (req, msg) => {
msg.body += "\nUnknow option";

if(req.prompt.trim() === "0"){
msg = options.redirect("main");
msg = redirect("main");
}

return msg;
Expand All @@ -59,7 +59,7 @@ options.form("profession", async (req, msg) => {
msg.body += "\nUnknow option";

if(req.prompt.trim() === "0"){
msg = options.redirect("main");
msg = redirect("main");
}

return msg;
Expand All @@ -75,4 +75,4 @@ message = await options.process({prompt:"0"}, message);
console.log(message);

message = await options.process({prompt:"2"}, message);
console.log(message);
console.log(format_message(message));
6 changes: 3 additions & 3 deletions examples/reverse.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Lottus } from "../index.js";
import { lottus, format_message } from "../index.js";

let bot = new Lottus();
let bot = lottus();

bot.info("main", async (req, res) => {
res.body = req.sentence.split("").reverse().join("");

return res;
});

console.log((await bot.process({sentence: "hello world"})));
console.log(format_message(await bot.process({sentence: "hello world"})));
4 changes: 2 additions & 2 deletions examples/reverse_with_params.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Lottus } from "../index.js";
import { lottus } from "../index.js";

let reverse = new Lottus();
let reverse = new lottus();

reverse.info("main", async (req, res) => {
res.body = "Unkonw language";
Expand Down
Loading

0 comments on commit 4b3e423

Please sign in to comment.