From 2c8812f45e6ec3dfda08a9a8da427f614a5cf53c Mon Sep 17 00:00:00 2001 From: Yiwen-Chan Date: Sun, 2 May 2021 18:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=A2=9E=E5=8A=A0github=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=BF=94=E5=9B=9E=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- github/repo_searcher.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/github/repo_searcher.go b/github/repo_searcher.go index 04eb228e..318e4e40 100644 --- a/github/repo_searcher.go +++ b/github/repo_searcher.go @@ -14,7 +14,7 @@ import ( ) func init() { // 插件主体 - zero.OnRegex(`^>github\s(.*)$`).SetBlock(true).FirstPriority(). + zero.OnRegex(`^>github\s(-.{1,10} )?(.*)$`).SetBlock(true).FirstPriority(). Handle(func(ctx *zero.Ctx) { // 发送请求 header := http.Header{ @@ -22,7 +22,7 @@ func init() { // 插件主体 } api, _ := url.Parse("https://api.github.com/search/repositories") api.RawQuery = url.Values{ - "q": []string{ctx.State["regex_matched"].([]string)[1]}, + "q": []string{ctx.State["regex_matched"].([]string)[2]}, }.Encode() body, err := netGet(api.String(), header) if err != nil { @@ -36,8 +36,13 @@ func init() { // 插件主体 } repo := info.Get("items.0") // 发送结果 - ctx.SendChain( - message.Text( + switch ctx.State["regex_matched"].([]string)[1] { + case "-pic ": // 图片模式 + ctx.SendChain(message.Image( + "https://opengraph.githubassets.com/0/"+repo.Get("full_name").Str, + ).Add("cache", 0)) + default: + ctx.SendChain(message.Text( repo.Get("full_name").Str, "\n", "Description: ", repo.Get("description").Str, "\n", @@ -51,8 +56,8 @@ func init() { // 插件主体 repo.Get("pushed_at").Str, "\n", "Jump: ", repo.Get("html_url").Str, "\n", - ), - ) + )) + } }) }