Skip to content

Commit

Permalink
Merge branch 'master' into patch-231230
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama authored May 4, 2024
2 parents d8def12 + 0e3c025 commit 5b6d112
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 108 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
55 changes: 48 additions & 7 deletions plugin/bilibili/bilibili_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -114,10 +120,10 @@ func handleVideo(ctx *zero.Ctx) {
if ok && c.GetData(ctx.Event.GroupID)&enableHex == enableHex {
summaryMsg, err := getVideoSummary(card)

Check failure on line 121 in plugin/bilibili/bilibili_parse.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, arm64)

not enough arguments in call to getVideoSummary

Check failure on line 121 in plugin/bilibili/bilibili_parse.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, amd64)

not enough arguments in call to getVideoSummary

Check failure on line 121 in plugin/bilibili/bilibili_parse.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, arm)

not enough arguments in call to getVideoSummary

Check failure on line 121 in plugin/bilibili/bilibili_parse.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, 386)

not enough arguments in call to getVideoSummary
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...)
}
Expand Down Expand Up @@ -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
}
26 changes: 0 additions & 26 deletions plugin/bilibili/card2msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
8 changes: 0 additions & 8 deletions plugin/bilibili/card2msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
52 changes: 0 additions & 52 deletions plugin/emojimix/emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion plugin/emojimix/mix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions plugin/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
// 入群欢迎
Expand Down

0 comments on commit 5b6d112

Please sign in to comment.