-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
42 lines (38 loc) · 893 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
package main
import (
"context"
"fmt"
"time"
"github.com/dezhishen/onebot-sdk/pkg/config"
"github.com/dezhishen/onebot-sdk/pkg/event"
"github.com/dezhishen/onebot-sdk/pkg/model"
"github.com/sirupsen/logrus"
)
func main() {
conf, err := config.LoadConfig("http-reverse")
// conf, err := config.LoadConfig("websocket-reverse")
// conf, err := config.LoadConfig("websocket")
if err != nil {
panic(err)
}
eventCli, err := event.NewOnebotEventCli(conf.Event)
if err != nil {
panic(err)
}
eventCli.ListenMessageGroup(func(data model.EventMessageGroup) error {
if data.Message[0].Type == "text" {
fmt.Println(data.Message[0].Data)
}
return nil
})
ctx, cancel := context.WithCancel(context.Background())
go func() {
time.Sleep(10 * time.Minute)
logrus.Info("cancel...")
cancel()
}()
err = eventCli.StartListenWithCtx(ctx)
if err != nil {
panic(err)
}
}