diff --git a/plugin/bilibili/bilibili_parse.go b/plugin/bilibili/bilibili_parse.go index 5b28c077a8..5d3e73f603 100644 --- a/plugin/bilibili/bilibili_parse.go +++ b/plugin/bilibili/bilibili_parse.go @@ -55,6 +55,35 @@ func init() { handleLive(ctx) } }) + en.OnRegex(`^(.*)视频总结$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + gid := ctx.Event.GroupID + if gid <= 0 { + // 个人用户设为负数 + gid = -ctx.Event.UserID + } + option := ctx.State["regex_matched"].([]string)[1] + c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + if ok { + data := c.GetData(ctx.Event.GroupID) + switch option { + case "开启", "打开", "启用": + data |= 0x10 + case "关闭", "关掉", "禁用": + data &= 0x7fffffff_fffffffd + default: + return + } + err := c.SetData(gid, data) + if err == nil { + ctx.SendChain(message.Text("已", option)) + return + } + ctx.SendChain(message.Text("出错啦: ", err)) + return + } + ctx.SendChain(message.Text("找不到服务!")) + }) en.OnRegex(searchVideo).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleVideo) en.OnRegex(searchDynamic).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleDynamic) en.OnRegex(searchArticle).SetBlock(true).Limit(limit.LimitByGroup).Handle(handleArticle) @@ -76,12 +105,15 @@ func handleVideo(ctx *zero.Ctx) { ctx.SendChain(message.Text("ERROR: ", err)) return } - summaryMsg, err := getVideoSummary(card) - if err != nil { - ctx.SendChain(message.Text("ERROR: ", err)) - return + c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + if ok && c.GetData(ctx.Event.GroupID)&0x10 == 0x10 { + summaryMsg, err := getVideoSummary(card) + if err != nil { + ctx.SendChain(message.Text("ERROR: ", err)) + return + } + msg = append(msg, summaryMsg...) } - msg = append(msg, summaryMsg...) ctx.SendChain(msg...) } diff --git a/plugin/saucenao/searcher.go b/plugin/saucenao/searcher.go index 843a16eba3..8bead6f775 100644 --- a/plugin/saucenao/searcher.go +++ b/plugin/saucenao/searcher.go @@ -110,10 +110,15 @@ func init() { // 插件主体 Handle(func(ctx *zero.Ctx) { // 开始搜索图片 pics, ok := ctx.State["image_url"].([]string) + showPic := false if !ok { ctx.SendChain(message.Text("ERROR: 未获取到图片链接")) return } + c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + if ok && c.GetData(ctx.Event.GroupID)&0x10 == 0x10 { + showPic = true + } ctx.SendChain(message.Text("少女祈祷中...")) for _, pic := range pics { if saucenaocli != nil { @@ -141,15 +146,17 @@ func init() { // 插件主体 } else { msg = append(msg, message.Text("也许是这个?")) } - if err == nil { - _ = resp.Body.Close() - if resp.StatusCode == http.StatusOK { - msg = append(msg, message.Image(result.Header.Thumbnail)) + if showPic { + if err == nil { + _ = resp.Body.Close() + if resp.StatusCode == http.StatusOK { + msg = append(msg, message.Image(result.Header.Thumbnail)) + } else { + msg = append(msg, message.Image(pic)) + } } else { msg = append(msg, message.Image(pic)) } - } else { - msg = append(msg, message.Image(pic)) } msg = append(msg, message.Text("\n图源: ", result.Header.IndexName, binary.BytesToString(b))) ctx.Send(message.Message{ctxext.FakeSenderForwardNode(ctx, msg...)}) @@ -169,17 +176,30 @@ func init() { // 插件主体 } msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))} for i := 0; i < len(result) && i < 5; i++ { - msg = append(msg, ctxext.FakeSenderForwardNode(ctx, - message.Image(result[i].Thumb), - message.Text(fmt.Sprintf( - "标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s", - result[i].Name, - result[i].Type, - result[i].AuthNm, - result[i].Author, - result[i].Link, - ))), - ) + if showPic { + msg = append(msg, ctxext.FakeSenderForwardNode(ctx, + message.Image(result[i].Thumb), + message.Text(fmt.Sprintf( + "标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s", + result[i].Name, + result[i].Type, + result[i].AuthNm, + result[i].Author, + result[i].Link, + ))), + ) + } else { + msg = append(msg, ctxext.FakeSenderForwardNode(ctx, + message.Text(fmt.Sprintf( + "标题: %s\n图源: %s\n画师: %s\n画师链接: %s\n图片链接: %s", + result[i].Name, + result[i].Type, + result[i].AuthNm, + result[i].Author, + result[i].Link, + ))), + ) + } } if id := ctx.Send(msg).ID(); id == 0 { ctx.SendChain(message.Text("ERROR: 可能被风控了")) @@ -204,4 +224,33 @@ func init() { // 插件主体 } ctx.SendChain(message.Text("成功!")) }) + engine.OnRegex(`^(.*)搜图显示图片$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true). + Handle(func(ctx *zero.Ctx) { + gid := ctx.Event.GroupID + if gid <= 0 { + // 个人用户设为负数 + gid = -ctx.Event.UserID + } + option := ctx.State["regex_matched"].([]string)[1] + c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx]) + if ok { + data := c.GetData(ctx.Event.GroupID) + switch option { + case "开启", "打开", "启用": + data |= 0x10 + case "关闭", "关掉", "禁用": + data &= 0x7fffffff_fffffffd + default: + return + } + err := c.SetData(gid, data) + if err == nil { + ctx.SendChain(message.Text("已", option)) + return + } + ctx.SendChain(message.Text("出错啦: ", err)) + return + } + ctx.SendChain(message.Text("找不到服务!")) + }) }