-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (37 loc) · 669 Bytes
/
main.go
File metadata and controls
41 lines (37 loc) · 669 Bytes
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
package main
import (
"bufio"
"os"
"strings"
"log"
"github.com/biezhi/agon/color"
)
func ReadInput() {
inputReader := bufio.NewReader(os.Stdin)
color.Print(color.Yellow, "You: ")
input, err := inputReader.ReadString('\n')
if err == nil {
if strings.EqualFold("quit", strings.TrimSpace(input)) ||
strings.EqualFold("exit", strings.TrimSpace(input)) {
os.Exit(3)
} else {
result := tlAI(input)
color.Print(color.Green, "Robot: ")
color.Println(color.Purple, result)
}
}
}
// start robot
func Start() {
for {
ReadInput()
}
}
func main() {
// init config
if err := InitConf(); err != nil {
log.Fatal(err)
} else {
Start()
}
}