diff --git a/go.mod b/go.mod index 02ff20b422..7f691e0f0d 100644 --- a/go.mod +++ b/go.mod @@ -4,15 +4,15 @@ go 1.20 require ( github.com/Baidu-AIP/golang-sdk v1.1.1 - github.com/FloatTech/AnimeAPI v1.7.1-0.20240502092440-2cf39e6d08c1 + github.com/FloatTech/AnimeAPI v1.7.1-0.20240504155718-e1a4844e94a5 github.com/FloatTech/floatbox v0.0.0-20240504085530-b2994112ec50 github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 github.com/FloatTech/sqlite v1.6.3 github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1 - github.com/FloatTech/zbpctrl v1.6.1-0.20240501122621-27fbe564d42a - github.com/FloatTech/zbputils v1.7.1-0.20240504124534-d8208d13abea + github.com/FloatTech/zbpctrl v1.6.1 + github.com/FloatTech/zbputils v1.7.1-0.20240504134720-ce2b1be4b85a github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7 github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5 github.com/antchfx/htmlquery v1.2.5 @@ -40,7 +40,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/tidwall/gjson v1.14.4 github.com/wcharczuk/go-chart/v2 v2.1.0 - github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240501144516-eb574bbdad32 + github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240504144809-0d0388f8f575 gitlab.com/gomidi/midi/v2 v2.0.25 golang.org/x/image v0.3.0 golang.org/x/sys v0.19.0 diff --git a/go.sum b/go.sum index aacdfbc69c..683d29471f 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhv github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/FloatTech/AnimeAPI v1.7.1-0.20240502092440-2cf39e6d08c1 h1:jCHd5jhWyycMoCKh4Sjx4oyoRv99uB7ZuRrjeA3ZErk= -github.com/FloatTech/AnimeAPI v1.7.1-0.20240502092440-2cf39e6d08c1/go.mod h1:Ru6q5pZUnfMg1iu0M1Hp73q9N3LNIbDr16kjkzyG6Xk= +github.com/FloatTech/AnimeAPI v1.7.1-0.20240504155718-e1a4844e94a5 h1:0Xgngi3sWMnnvdl5PZapu4sWP5fp7ftmYMy5eIGKMdM= +github.com/FloatTech/AnimeAPI v1.7.1-0.20240504155718-e1a4844e94a5/go.mod h1:Ru6q5pZUnfMg1iu0M1Hp73q9N3LNIbDr16kjkzyG6Xk= github.com/FloatTech/floatbox v0.0.0-20240504085530-b2994112ec50 h1:1D9BS5nI8UFQ8dg3QJicntfGbtL5WdZsKm/OMyBd/lM= github.com/FloatTech/floatbox v0.0.0-20240504085530-b2994112ec50/go.mod h1:OzGLhvmtz1TKIdGaJDd8pQumvD36UqK+dWsiCISmzQQ= github.com/FloatTech/gg v1.1.3-0.20230226151425-6ea91286ba08 h1:dPLeoiTVSBlgls+66EB/UJ2e38BaASmBN5nANaycSBU= @@ -16,10 +16,10 @@ github.com/FloatTech/sqlite v1.6.3 h1:MQkqBNlkPuCoKQQgoNLuTL/2Ci3tBTFAnVYBdD0Wy4 github.com/FloatTech/sqlite v1.6.3/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1 h1:g4pTnDJUW4VbJ9NvoRfUvdjDrHz/6QhfN/LoIIpICbo= github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= -github.com/FloatTech/zbpctrl v1.6.1-0.20240501122621-27fbe564d42a h1:9HPKT4WuO5nYVxVRie7OTn2kV9cwaktulkZbBbCqXkg= -github.com/FloatTech/zbpctrl v1.6.1-0.20240501122621-27fbe564d42a/go.mod h1:RxqNENMwHUUZz5IazDxhnmyejGV0xQthYpScMU9cWbw= -github.com/FloatTech/zbputils v1.7.1-0.20240504124534-d8208d13abea h1:rJvWRrdgk1+QUy8UxHSSMY21r3U6jxQhTW/AWIGiIaY= -github.com/FloatTech/zbputils v1.7.1-0.20240504124534-d8208d13abea/go.mod h1:caNGFADPaEkZvuaECwGA1I7t6nJuK+TcxNaTjLa4OYs= +github.com/FloatTech/zbpctrl v1.6.1 h1:SilK5R2poO8iUT6JPzpgr/BSzxYAaybBYNZkMyZ8STw= +github.com/FloatTech/zbpctrl v1.6.1/go.mod h1:I+MetM++1sJhNPg3zww1aw04BicYsNohvHC4Jh52XSo= +github.com/FloatTech/zbputils v1.7.1-0.20240504134720-ce2b1be4b85a h1:tjpvpv8Elnj2w+MSE9lu1qrghfpVU1zNw8ngKZS1H4A= +github.com/FloatTech/zbputils v1.7.1-0.20240504134720-ce2b1be4b85a/go.mod h1:drCjiDLLtRIfN9sRJKJneReZmn/LsBGB8TWYgEoWrA0= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7 h1:S/ferNiehVjNaBMNNBxUjLtVmP/YWD6Yh79RfPv4ehU= github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= @@ -196,8 +196,8 @@ github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYm github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I= github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA= -github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240501144516-eb574bbdad32 h1:GuVwh4uGtDegpKNgSkcqpbISLAn5nCpqoGxXmiEv4iI= -github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240501144516-eb574bbdad32/go.mod h1:J6uHaXS/Am2VsLxF9TcU6il19PbOeC4SvgxHJ1E2jaE= +github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240504144809-0d0388f8f575 h1:98GpzXVAgqNCLF4B7MwmVLW08MDhfyx62Fz6aqCwO3M= +github.com/wdvxdr1123/ZeroBot v1.7.5-0.20240504144809-0d0388f8f575/go.mod h1:J6uHaXS/Am2VsLxF9TcU6il19PbOeC4SvgxHJ1E2jaE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= diff --git a/plugin/bilibili/bilibili_parse.go b/plugin/bilibili/bilibili_parse.go index 6152a1d7c2..d9d8c144cf 100644 --- a/plugin/bilibili/bilibili_parse.go +++ b/plugin/bilibili/bilibili_parse.go @@ -2,10 +2,15 @@ package bilibili import ( + "encoding/json" + "fmt" + "net/http" "regexp" + "strings" "time" bz "github.com/FloatTech/AnimeAPI/bilibili" + "github.com/FloatTech/floatbox/web" ctrl "github.com/FloatTech/zbpctrl" "github.com/FloatTech/zbputils/control" "github.com/FloatTech/zbputils/ctxext" @@ -37,10 +42,11 @@ func init() { Brief: "b站链接解析", Help: "例:- t.bilibili.com/642277677329285174\n- bilibili.com/read/cv17134450\n- bilibili.com/video/BV13B4y1x7pS\n- live.bilibili.com/22603245 ", }) - en.OnRegex(`((b23|acg).tv|bili2233.cn)/[0-9a-zA-Z]+`).SetBlock(true).Limit(limit.LimitByGroup). + en.OnRegex(`((b23|acg).tv|bili2233.cn)\\?/[0-9a-zA-Z]+`).SetBlock(true).Limit(limit.LimitByGroup). Handle(func(ctx *zero.Ctx) { - url := ctx.State["regex_matched"].([]string)[0] - realurl, err := bz.GetRealURL("https://" + url) + u := ctx.State["regex_matched"].([]string)[0] + u = strings.ReplaceAll(u, "\\", "") + realurl, err := bz.GetRealURL("https://" + u) if err != nil { ctx.SendChain(message.Text("ERROR: ", err)) return @@ -114,10 +120,10 @@ func handleVideo(ctx *zero.Ctx) { if ok && c.GetData(ctx.Event.GroupID)&enableHex == enableHex { summaryMsg, err := getVideoSummary(card) if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return - } - msg = append(msg, summaryMsg...) + msg = append(msg, message.Text("ERROR: ", err)) + } else { + msg = append(msg, summaryMsg...) + } } ctx.SendChain(msg...) } @@ -148,3 +154,38 @@ func handleLive(ctx *zero.Ctx) { } ctx.SendChain(liveCard2msg(card)...) } + +// getVideoSummary AI视频总结 +func getVideoSummary(cookiecfg *bz.CookieConfig, card bz.Card) (msg []message.MessageSegment, err error) { + var ( + data []byte + videoSummary bz.VideoSummary + ) + data, err = web.RequestDataWithHeaders(web.NewDefaultClient(), bz.SignURL(fmt.Sprintf(bz.VideoSummaryURL, card.BvID, card.CID, card.Owner.Mid)), "GET", func(req *http.Request) error { + if cookiecfg != nil { + cookie := "" + cookie, err = cookiecfg.Load() + if err != nil { + return err + } + req.Header.Add("cookie", cookie) + } + req.Header.Set("User-Agent", ua) + return nil + }, nil) + if err != nil { + return + } + err = json.Unmarshal(data, &videoSummary) + msg = make([]message.MessageSegment, 0, 16) + msg = append(msg, message.Text("已为你生成视频总结\n\n")) + msg = append(msg, message.Text(videoSummary.Data.ModelResult.Summary, "\n\n")) + for _, v := range videoSummary.Data.ModelResult.Outline { + msg = append(msg, message.Text("● ", v.Title, "\n")) + for _, p := range v.PartOutline { + msg = append(msg, message.Text(fmt.Sprintf("%d:%d %s\n", p.Timestamp/60, p.Timestamp%60, p.Content))) + } + msg = append(msg, message.Text("\n")) + } + return +} diff --git a/plugin/bilibili/card2msg.go b/plugin/bilibili/card2msg.go index 55868a31e0..5d3b2f3fe0 100644 --- a/plugin/bilibili/card2msg.go +++ b/plugin/bilibili/card2msg.go @@ -2,12 +2,10 @@ package bilibili import ( "encoding/json" - "fmt" "time" bz "github.com/FloatTech/AnimeAPI/bilibili" "github.com/FloatTech/floatbox/binary" - "github.com/FloatTech/floatbox/web" "github.com/wdvxdr1123/ZeroBot/message" ) @@ -326,27 +324,3 @@ func videoCard2msg(card bz.Card) (msg []message.MessageSegment, err error) { bz.VURL, card.BvID, "\n\n")) return } - -// getVideoSummary AI视频总结 -func getVideoSummary(card bz.Card) (msg []message.MessageSegment, err error) { - var ( - data []byte - videoSummary bz.VideoSummary - ) - data, err = web.GetData(bz.SignURL(fmt.Sprintf(bz.VideoSummaryURL, card.BvID, card.CID))) - if err != nil { - return - } - err = json.Unmarshal(data, &videoSummary) - msg = make([]message.MessageSegment, 0, 16) - msg = append(msg, message.Text("已为你生成视频总结\n\n")) - msg = append(msg, message.Text(videoSummary.Data.ModelResult.Summary, "\n\n")) - for _, v := range videoSummary.Data.ModelResult.Outline { - msg = append(msg, message.Text("● ", v.Title, "\n")) - for _, p := range v.PartOutline { - msg = append(msg, message.Text(fmt.Sprintf("%d:%d %s\n", p.Timestamp/60, p.Timestamp%60, p.Content))) - } - msg = append(msg, message.Text("\n")) - } - return -} diff --git a/plugin/bilibili/card2msg_test.go b/plugin/bilibili/card2msg_test.go index e56a5c8f3d..5c43c8491c 100644 --- a/plugin/bilibili/card2msg_test.go +++ b/plugin/bilibili/card2msg_test.go @@ -46,14 +46,6 @@ func TestVideoInfo(t *testing.T) { t.Log(videoCard2msg(card)) } -func TestGetVideoSummary(t *testing.T) { - card, err := bz.GetVideoInfo("BV1mF411j7iU") - if err != nil { - t.Fatal(err) - } - t.Log(getVideoSummary(card)) -} - func TestLiveRoomInfo(t *testing.T) { card, err := bz.GetLiveRoomInfo("83171") if err != nil { diff --git a/plugin/emojimix/emoji.go b/plugin/emojimix/emoji.go index 487ff3ba6f..b892153b25 100644 --- a/plugin/emojimix/emoji.go +++ b/plugin/emojimix/emoji.go @@ -195,55 +195,3 @@ var emojis = map[rune]int64{ 127819: 20210521, // 🍋 lemon 127818: 20211115, // 🍊 tangerine orange } - -var qqface = map[int]rune{ - 0: 128558, // 😮 face exhaling - 1: 128556, // 😬 grimacing face - 2: 128525, // 😍 smiling face with heart-eyes - 4: 128526, // 😎 smiling face with sunglasses - 5: 128557, // 😭 loudly crying face - 6: 129402, // 🥺 pleading face - 7: 129296, // 🤐 zipper-mouth face - 8: 128554, // 😪 sleepy face - 11: 128545, // 😡 pouting face - 12: 128539, // 😛 face with tongue - 13: 128513, // 😁 beaming face with smiling eyes - 14: 128578, // 🙂 slightly smiling face - 15: 128577, // 🙁 slightly frowning face - 16: 128526, // 😎 smiling face with sunglasses - 19: 129326, // 🤮 face vomiting throw - 20: 129325, // 🤭 face with hand over mouth embarrassed - 21: 128522, // 😊 smiling face with smiling eyes - 23: 128533, // 😕 confused face - 24: 128523, // 😋 face savoring food - 27: 128531, // 😓 downcast face with sweat - 28: 128516, // 😄 grinning face with smiling eyes - 31: 129324, // 🤬 face with symbols on mouth - 32: 129300, // 🤔 thinking face question hmmm - 33: 129323, // 🤫 shushing face quiet whisper - 34: 128565, // 😵 face with crossed-out eyes - 35: 128547, // 😣 persevering face - 37: 128128, // 💀 skull - 46: 128055, // 🐷 pig face - 53: 127874, // 🎂 birthday cake - 59: 128169, // 💩 pile of poo - 60: 9749, // ☕ hot beverage coffee cup tea - 63: 127801, // 🌹 rose flower - 66: 10084, // ❤ mending heart - 67: 128148, // 💔 broken heart - 69: 127873, // 🎁 wrapped-gift - 74: 127774, // 🌞 sun with face - 75: 127772, // 🌜 last quarter moon face - 96: 128517, // 😅 grinning face with sweat - 104: 129393, // 🥱 yawning face - 109: 128535, // 😗 kissing face - 110: 128562, // 😲 astonished face - 111: 129402, // 🥺 pleading face - 172: 128539, // 😛 face with tongue - 182: 128514, // 😂 face with tears of joy - 187: 128123, // 👻 ghost - 247: 128567, // 😷 face with medical mask - 272: 128579, // 🙃 upside-down face - 320: 129395, // 🥳 partying face - 325: 128561, // 😱 face screaming in fear -} diff --git a/plugin/emojimix/mix.go b/plugin/emojimix/mix.go index 2305b89205..a73df488af 100644 --- a/plugin/emojimix/mix.go +++ b/plugin/emojimix/mix.go @@ -113,7 +113,7 @@ func face2emoji(face message.MessageSegment) rune { if err != nil { return 0 } - if r, ok := qqface[id]; ok { + if r, ok := message.Emoji[id]; ok { return r } return 0 diff --git a/plugin/manager/manager.go b/plugin/manager/manager.go index 25ad2917af..4e7b0952c2 100644 --- a/plugin/manager/manager.go +++ b/plugin/manager/manager.go @@ -407,8 +407,19 @@ func init() { // 插件主体 Handle(func(ctx *zero.Ctx) { msgid := ctx.State["regex_matched"].([]string)[1] face := ctx.State["regex_matched"].([]string)[2] - if len(face) > 0 { - _ = ctx.SetMessageEmojiLike(msgid, face) + if len(face) == 0 { + ctx.SendChain(message.Text("ERROR: 表情长度为 0")) + return + } + x := []rune(face) + if len(x) == 0 { + ctx.SendChain(message.Text("ERROR: 解析后表情长度为 0")) + return + } + err := ctx.SetMessageEmojiLike(msgid, x[0]) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return } }) // 入群欢迎