-
Notifications
You must be signed in to change notification settings - Fork 0
/
diru.go
65 lines (51 loc) · 1 KB
/
diru.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 (
"flag"
"os"
"os/signal"
"syscall"
"github.com/5elenay/revoltgo"
"github.com/lucxjo/diru-revolt/cfg"
)
var dev bool
func initFlags() {
flag.BoolVar(&dev, "d", false, "Run in development mode")
flag.Parse()
}
func main() {
initFlags()
var config cfg.DiruConfig
if dev {
config = cfg.GetConfig("_diru")
} else {
config = cfg.GetConfig("diru")
}
// Init a new client.
client := revoltgo.Client{
Token: config.Revolt.Token,
}
// Listen a on message event.
client.OnMessage(func(m *revoltgo.Message) {
if m.AuthorId == config.Revolt.Uid {
return
}
if m.Content == "!ping" {
sendMsg := &revoltgo.SendMessage{}
sendMsg.SetContent("!pong")
m.Reply(true, sendMsg)
}
})
// Start the client.
client.Start()
// Wait for close.
sc := make(chan os.Signal, 1)
signal.Notify(
sc,
syscall.SIGINT,
syscall.SIGTERM,
os.Interrupt,
)
<-sc
// Destroy client.
client.Destroy()
}