-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord.go
53 lines (50 loc) · 1.42 KB
/
discord.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
package seadisc
import (
"encoding/json"
"log"
)
type SeaEvent struct {
Event string `json:"event"`
Payload struct {
EventType string `json:"item_transferred"`
Payload struct {
Collection struct {
Slug string `json:"slug"`
} `json:"collection"`
EventTimestamp string `json:"event_timestamp"`
FromAccount struct {
Address string `json:"address"`
} `json:"from_account"`
ToAccount struct {
Address string `json:"address"`
} `json:"to_account"`
Item struct {
Chain struct {
Name string `json:"name"`
} `json:"chain"`
MetaData struct {
AnimationUrl string `json:"animation_url"`
ImageUrl string `json:"image_url"`
MetaDataUrl string `json:"metadata_url"`
Name string `json:"name"`
} `json:"metadata"`
NFTid string `json:"nft_id"`
Permalink string `json:"permalink"`
} `json:"item"`
Quantity int `json:"quantity"`
Transaction struct {
Hash string `json:"hash"`
Timestamp string `json:"timestamp"`
} `json:"transaction"`
SentAt string `json:"sent_at"`
} `json:"payload"`
Ref string `jspn:"ref"`
Topic string `json:"topic"`
} `json:"payload"`
}
func Discord(message []byte) {
var event SeaEvent
_ = json.Unmarshal(message, &event)
log.Printf("%v : %v : %v", event.Event, event.Payload.Payload.FromAccount.Address, event.Payload.Payload.ToAccount.Address)
// log.Printf("recv: %s", message)
}