Skip to content

Commit

Permalink
⚡ add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Akegarasu committed Sep 11, 2022
1 parent 7c59d63 commit 24c237f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions example/dump/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"fmt"
"github.com/Akegarasu/blivedm-go/client"
_ "github.com/Akegarasu/blivedm-go/utils"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
)

const roomId = "8792912"

var dumps = []string{"GUARD_BUY", "USER_TOAST_MSG"}

func main() {
log.SetLevel(log.DebugLevel)
c := client.NewClient(roomId)
for _, v := range dumps {
vv := v
c.RegisterCustomEventHandler(vv, func(s string) {
data := gjson.Get(s, "data").String()
fmt.Printf("[%s] %s\n", vv, data)
})
}
err := c.Start()
if err != nil {
log.Fatal(err)
}
log.Println("started bili dumper")
select {}
}

0 comments on commit 24c237f

Please sign in to comment.