deno.land / x / treebot@v0.0.6 / examples / example.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { TreeBot, TreeTask, BranchTask, LeafTask } from 'https://deno.land/x/treebot/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();
treebot

Version Info

Tagged at
3 years ago

External Dependencies

1 external dependency