Skip to content

Commit 685f7fd

Browse files
Update bilibili_parse.go 增加 BV码 识别的方式
增加 BV码 识别的方式
1 parent e6a4dfc commit 685f7fd

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

plugin/bilibili/bilibili_parse.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ func init() {
7878
handleLive(ctx)
7979
}
8080
})
81+
en.OnRegex(`^([BV][A-Za-z0-9]+)`).SetBlock(true).Limit(limit.LimitByGroup).
82+
Handle(func(ctx *zero.Ctx) {
83+
u := ctx.State["regex_matched"].([]string)[0]
84+
if !strings.Contains(u, "bilibili") {
85+
u = "bilibili.com/video/" + u
86+
}
87+
var bilibiliurl string
88+
bilibiliurl = "https://" + u
89+
if searchVideoRe.MatchString(bilibiliurl){
90+
ctx.State["regex_matched"] = searchVideoRe.FindStringSubmatch(bilibiliurl)
91+
handleVideo(ctx)
92+
}
93+
})
8194
en.OnRegex(`^(开启|打开|启用|关闭|关掉|禁用)视频总结$`, zero.AdminPermission).SetBlock(true).
8295
Handle(func(ctx *zero.Ctx) {
8396
gid := ctx.Event.GroupID

0 commit comments

Comments
 (0)