An open API service indexing awesome lists of open source software.

https://github.com/dylanblokhuis/treebot

treebot framework to create decision trees in deno/node
https://github.com/dylanblokhuis/treebot

bot deno typescript

Last synced: 2 months ago
JSON representation

treebot framework to create decision trees in deno/node

Awesome Lists containing this project

README

          

# TreeBot framework for deno/node

## Example:
```typescript
import { TreeBot, TreeTask, BranchTask, LeafTask } from './mod.ts'

class IsSunday extends BranchTask {
validate() {
return (new Date().getDay()) === 0
}

successTask() {
return new LogSunday();
}

failureTask() {
return new LogNotSunday();
}
}

class LogSunday extends LeafTask {
execute() {
console.log('Its sunday today!')
}
}

class LogNotSunday extends LeafTask {
execute() {
console.log('Its not sunday today!')
}
}

class ExampleBot extends TreeBot {
createRootTask(): TreeTask {
return new IsSunday();
}

onLoop() {
console.log("Loop!!");
}

onStart() {
console.log("Started");
}
}

const bot = new ExampleBot();
bot.run();
```