From: qydysky Date: Sun, 28 Jul 2024 07:21:49 +0000 (+0800) Subject: Improve 过滤表情字符 X-Git-Tag: v0.14.13~3 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=19c70453747f86c98590dcb33ae462a708b8f331;p=bili_danmu%2F.git Improve 过滤表情字符 --- diff --git a/Reply/F/danmuEmotes/danmuEmotes.go b/Reply/F/danmuEmotes/danmuEmotes.go index afc3d44..81e7e70 100644 --- a/Reply/F/danmuEmotes/danmuEmotes.go +++ b/Reply/F/danmuEmotes/danmuEmotes.go @@ -15,6 +15,7 @@ import ( // path var ( SaveEmote = comp.NewComp(saveEmote) + replace = strings.NewReplacer(`| `, `\ `, `/ `, `: `, `* `, `? `, `" `, `< `, `> `, `| `) ) type Danmu struct { @@ -35,7 +36,7 @@ func saveEmote(ctx context.Context, ptr Danmu) (ret any, err error) { *ptr.Msg = "[" + *ptr.Msg + emoticon_unique + "]" } } - savePath := "emots/" + *ptr.Msg + ".png" + savePath := "emots/" + replace.Replace(*ptr.Msg) + ".png" if !file.New(savePath, 0, true).IsExist() { go func() { req := c.C.ReqPool.Get() @@ -81,7 +82,7 @@ func saveEmote(ctx context.Context, ptr Danmu) (ret any, err error) { continue } - savePath := "emots/" + k + ".png" + savePath := "emots/" + replace.Replace(k) + ".png" if file.New(savePath, 0, true).IsExist() { continue }