mirror of
https://github.com/AynaLivePlayer/blivedm-go.git
synced 2025-12-09 04:38:13 +08:00
🎨 byte-string convert
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"github.com/Akegarasu/blivedm-go/utils"
|
||||||
"encoding/json"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
@@ -111,9 +110,9 @@ type ComboSend struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Gift) Parse(data []byte) {
|
func (g *Gift) Parse(data []byte) {
|
||||||
sb := bytes.NewBuffer(data).String()
|
sb := utils.BytesToString(data)
|
||||||
sd := gjson.Get(sb, "data").String()
|
sd := gjson.Get(sb, "data").String()
|
||||||
err := json.Unmarshal([]byte(sd), g)
|
err := utils.UnmarshalString(sd, g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("parse Gift failed")
|
log.Error("parse Gift failed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"github.com/Akegarasu/blivedm-go/utils"
|
||||||
"encoding/json"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
@@ -20,9 +19,9 @@ type GuardBuy struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GuardBuy) Parse(data []byte) {
|
func (g *GuardBuy) Parse(data []byte) {
|
||||||
sb := bytes.NewBuffer(data).String()
|
sb := utils.BytesToString(data)
|
||||||
sd := gjson.Get(sb, "data").String()
|
sd := gjson.Get(sb, "data").String()
|
||||||
err := json.Unmarshal([]byte(sd), g)
|
err := utils.UnmarshalString(sd, g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("parse GuardBuy failed")
|
log.Error("parse GuardBuy failed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"github.com/Akegarasu/blivedm-go/utils"
|
||||||
"encoding/json"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
@@ -72,9 +71,9 @@ type SuperChat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SuperChat) Parse(data []byte) {
|
func (s *SuperChat) Parse(data []byte) {
|
||||||
sb := bytes.NewBuffer(data).String()
|
sb := utils.BytesToString(data)
|
||||||
sd := gjson.Get(sb, "data").String()
|
sd := gjson.Get(sb, "data").String()
|
||||||
err := json.Unmarshal([]byte(sd), s)
|
err := utils.UnmarshalString(sd, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("parse superchat failed")
|
log.Error("parse superchat failed")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user