-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (44 loc) · 1004 Bytes
/
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
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
"github.com/bwmarrin/discordgo"
"github.com/joho/godotenv"
"github.com/newt239/owl/functions"
"github.com/newt239/owl/handlers"
)
func main() {
godotenv.Load(".env")
discord, err := discordgo.New("Bot " + os.Getenv("TOKEN"))
if err != nil {
fmt.Println("ログインに失敗しました")
fmt.Println(err)
}
discord.AddHandler(handlers.OnMessageCreate)
discord.Open()
if err != nil {
fmt.Println(err)
}
defer discord.Close()
fmt.Println("owl is running")
functions.GetShipNews(discord)
functions.GetNarou(discord)
ticker := time.NewTicker(time.Hour)
fmt.Println("タイマーを開始")
go func() {
for t := range ticker.C {
fmt.Println(t)
functions.GetShipNews(discord)
functions.GetNarou(discord)
if t.Hour() == 5 {
functions.GetWeather(discord)
}
}
}()
stopBot := make(chan os.Signal, 1)
signal.Notify(stopBot, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-stopBot
}