From 7b5547f0b0674c3bdba9431c0e849d657bd6b28c Mon Sep 17 00:00:00 2001 From: Akegarasu Date: Tue, 3 Jun 2025 13:40:51 +0800 Subject: [PATCH 1/2] more danmaku extra, close #28 --- message/danmu.go | 51 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/message/danmu.go b/message/danmu.go index 0075c5a..1d26c87 100644 --- a/message/danmu.go +++ b/message/danmu.go @@ -25,20 +25,43 @@ type ( } Extra struct { - SendFromMe bool `json:"send_from_me"` - Mode int `json:"mode"` - Color int `json:"color"` - DmType int `json:"dm_type"` - FontSize int `json:"font_size"` - PlayerMode int `json:"player_mode"` - ShowPlayerType int `json:"show_player_type"` - Content string `json:"content"` - UserHash string `json:"user_hash"` - EmoticonUnique string `json:"emoticon_unique"` - Direction int `json:"direction"` - PkDirection int `json:"pk_direction"` - SpaceType string `json:"space_type"` - SpaceUrl string `json:"space_url"` + SendFromMe bool `json:"send_from_me"` + MasterPlayerHidden bool `json:"master_player_hidden"` + Mode int `json:"mode"` + Color int `json:"color"` + DmType int `json:"dm_type"` + FontSize int `json:"font_size"` + PlayerMode int `json:"player_mode"` + ShowPlayerType int `json:"show_player_type"` + Content string `json:"content"` + UserHash string `json:"user_hash"` + EmoticonUnique string `json:"emoticon_unique"` + BulgeDisplay int `json:"bulge_display"` + RecommendScore int `json:"recommend_score"` + MainStateDmColor string `json:"main_state_dm_color"` + ObjectiveStateDmColor string `json:"objective_state_dm_color"` + Direction int `json:"direction"` + PkDirection int `json:"pk_direction"` + QuartetDirection int `json:"quartet_direction"` + AnniversaryCrowd int `json:"anniversary_crowd"` + YeahSpaceType string `json:"yeah_space_type"` + YeahSpaceURL string `json:"yeah_space_url"` + JumpToURL string `json:"jump_to_url"` + SpaceType string `json:"space_type"` + SpaceURL string `json:"space_url"` + // Animation any `json:"animation"` + // Emots any `json:"emots"` + IsAudited bool `json:"is_audited"` + IDStr string `json:"id_str"` + // Icon any `json:"icon"` + ShowReply bool `json:"show_reply"` + ReplyMid int `json:"reply_mid"` + ReplyUname string `json:"reply_uname"` + ReplyUnameColor string `json:"reply_uname_color"` + ReplyIsMystery bool `json:"reply_is_mystery"` + ReplyTypeEnum int `json:"reply_type_enum"` + HitCombo int `json:"hit_combo"` + EsportsJumpURL string `json:"esports_jump_url"` } Emoticon struct { BulgeDisplay int `json:"bulge_display"` From 11da71ddc0356534119e0abd1a4c219450edf10d Mon Sep 17 00:00:00 2001 From: Akegarasu Date: Tue, 3 Jun 2025 14:18:30 +0800 Subject: [PATCH 2/2] modern convert --- utils/strconv.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/utils/strconv.go b/utils/strconv.go index ccd714f..4a2f526 100644 --- a/utils/strconv.go +++ b/utils/strconv.go @@ -6,16 +6,17 @@ import ( ) func StringToBytes(s string) []byte { - return *(*[]byte)(unsafe.Pointer( - &struct { - string - Cap int - }{s, len(s)}, - )) + if len(s) == 0 { + return nil + } + return unsafe.Slice(unsafe.StringData(s), len(s)) } func BytesToString(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) + if len(b) == 0 { + return "" + } + return unsafe.String(unsafe.SliceData(b), len(b)) } func B64Decode(s string) ([]byte, error) {