forked from carsenolson/nektomebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
65 lines (57 loc) · 1.05 KB
/
main.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"./bot"
"strings"
"bufio"
"os"
"log"
)
func main() {
var tokens []string
var bots []*bot.Bot
file, err := os.Open("tokens/tokens")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
tokens = append(tokens, scanner.Text())
bots = append(bots, bot.NewBot())
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
for _, b := range bots {
b.Bots = &bots;
}
for i, b := range bots {
go b.Connect(tokens[i])
}
reader := bufio.NewReader(os.Stdin)
for {
text, _ := reader.ReadString('\n')
args := strings.Split(text, " ")
switch string(args[0]) {
case "track":
bots[0].Track()
case "untrack":
bots[0].UnTrack()
case "search":
bots[0].StartSearch()
case "leave":
bots[0].LeaveDialog()
case "close":
bots[0].Close()
case "connect":
bots[0].Connect(os.Args[1])
break
default:
wo := ""
for _, word := range args {
wo += word+" "
}
bots[0].SendMessage(wo)
}
}
}