mirror of
https://github.com/AynaLivePlayer/blivedm-go.git
synced 2025-12-06 19:32:49 +08:00
⚡ add more examples
This commit is contained in:
31
example/dump/main.go
Normal file
31
example/dump/main.go
Normal file
@@ -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 {}
|
||||
}
|
||||
Reference in New Issue
Block a user