Skip to content

Commit

Permalink
more complex heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaSd committed Mar 24, 2024
1 parent 1a14cf3 commit 38f8ff0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/deno_bot_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,29 @@ if (import.meta.main) {
// TODO
let lastResult = "";
let idx = 0;
let start = 0;
while (true) {
let { data: output, done } = await pty.read();
if (done) break;
output = stripAnsiCode(output).trim();
if (output && output !== "In:") lastResult = output;

if (!output && lastResult) {
if (output && start === 0) {
start = 1;
}
if (!output && start === 1) {
start = 2;
}
if (output && start === 2) {
start = 3;
}

if (start === 3 && !output && lastResult) {
idx++;
} else {
idx = 0;
}

if (idx === 5) {
const result = lastResult.replace(/^Out:/, "").trim();
return result;
Expand Down

0 comments on commit 38f8ff0

Please sign in to comment.