-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
116 lines (106 loc) · 3.11 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
"strings"
"syscall"
"github.com/unitoftime/nootbot/api"
"github.com/unitoftime/nootbot/cmd"
)
func main() {
commands := []cmd.Command{
cmd.Command{
Name: "!echo",
Description: "[message] - Make NootBot Noot!",
Handler: cmd.EchoCommander{},
},
cmd.Command{
Name: "!recursion",
Description: "[message] - Make NootBot enter a recursive command.",
Handler: cmd.RecursionCommander{},
},
cmd.Command{
Name: "!eval",
Description: "[nootlang command] - Evaluate arbitrary nootlang commands.",
Handler: cmd.NootlangCommander{},
},
cmd.Command{
Name: "!java",
Description: "[None] - Need inspiration for your next Java class?",
Handler: cmd.JavaCommander{},
},
cmd.Command{
Name: "!noot",
Description: "[None] - Feeling sad? NootBot has a way to make you happy!",
Handler: cmd.NootCommander{},
},
cmd.Command{
Name: "!poll",
Description: "[question] || [emojisArray] - You have questions, NootBot has answers!",
Handler: cmd.PollCommander{},
},
cmd.Command{
Name: "!weather",
Description: "[city] | [country code] | [units] - if there are same city names but in different countries, then add a \",\" after city name in [city] then followed by the country initials for the correct city",
Handler: cmd.NewWeatherCommander("weatherApi.token"),
},
cmd.Command{
Name: "!random",
Description: "[dog or cat] - Wanna see cute cat or dog image here it is!",
Handler: cmd.RandomCommander{},
},
cmd.Command{
Name: "!notify",
Description: "[notification] - This command can only be used by the one and only.",
// For now only non custom emojis are supported
Handler: cmd.NewNotificationCommander("notify.conf"),
},
// cmd.Command{
// Name: "!random",
// Handler: cmd.RandomCommander{},
// },
}
infoHandler := cmd.NewInfoCommander(commands)
infoCmd := cmd.Command{
Name: "!commands",
Handler: infoHandler,
}
infoCmd2 := cmd.Command{
Name: "!info",
Handler: infoHandler,
}
commands = append(commands, infoCmd)
commands = append(commands, infoCmd2)
if len(os.Args) < 2 {
log.Fatal("Must provide URL as first argument")
}
if os.Args[1] == "discord" {
token, err := ioutil.ReadFile("discord.token")
if err != nil {
panic(err)
}
discord := api.NewDiscord(strings.TrimSuffix(string(token), "\n"), commands)
discord.Listen()
} else if os.Args[1] != "test" {
livestreamId := os.Args[1]
log.Println(livestreamId)
ytToken, err := ioutil.ReadFile("token.json")
if err != nil {
log.Fatalf("Unable to read client secret file: %v", err)
}
youtube := api.NewYoutubeLive(ytToken, commands, livestreamId)
youtube.Listen()
} else {
test := api.NewTest(commands)
test.NootMessage("Starting Test API")
test.Listen()
}
// Wait here until CTRL-C or other term signal is received.
fmt.Println("Bot is now running. Press CTRL-C to exit.")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
}