-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (49 loc) · 1.21 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
package main
import (
"context"
"fmt"
"github.com/satori-protocol-go/satori-sdk-go/pkg/api"
"github.com/satori-protocol-go/satori-sdk-go/pkg/config"
"github.com/satori-protocol-go/satori-sdk-go/pkg/event"
)
func main() {
conf := config.SatoriConfig{
Api: config.SatoriApiConfig{
Type: "http",
Platform: "red",
SelfId: "11123456789",
Endpoint: "http://127.0.0.1:5140", //https://
},
Event: config.SatoriEventConfig{
Type: "websocket",
Addr: "ws://127.0.0.1:5140", // wss://
},
// Event: config.SatoriEventConfig{
// Type: "webhook",
// Addr: "0.0.0.0:8080", // 客户端服务的地址,127.0.0.1:8080 限制访问
// },
}
satoriApi, err := api.NewSatorApiByConfig(conf)
if err != nil {
panic(err)
}
guildList, err := satoriApi.GuildList("")
if err != nil {
fmt.Printf("err:%v", err)
} else {
fmt.Printf("guildList is :%v,next is :%s", guildList.Data, guildList.Next)
}
satoriEvent, err := event.NewSatorEventByConfig(conf)
if err != nil {
panic(err)
}
satoriEvent.ListenMessageCreated(func(e event.Event) error {
fmt.Printf("message.created %v", e)
return nil
})
ctx := context.Background()
err = satoriEvent.StartWithCtx(ctx)
if err != nil {
panic(err)
}
}