mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
✏️ 修复 github repo 搜索中文的问题
This commit is contained in:
parent
f534b52074
commit
14d07bf963
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
@ -13,7 +14,12 @@ import (
|
|||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
zero.OnRegex(`>G\s(.*)`).SetBlock(true).SetPriority(0).
|
zero.OnRegex(`>G\s(.*)`).SetBlock(true).SetPriority(0).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
link := "https://api.github.com/search/repositories?q=" + ctx.State["regex_matched"].([]string)[1]
|
api, _ := url.Parse("https://api.github.com/search/repositories")
|
||||||
|
params := url.Values{}
|
||||||
|
params.Set("q", ctx.State["regex_matched"].([]string)[1])
|
||||||
|
api.RawQuery = params.Encode()
|
||||||
|
link := api.String()
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", link, nil)
|
req, err := http.NewRequest("GET", link, nil)
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
// Str2Int string --> int64
|
// Str2Int string --> int64
|
||||||
func Str2Int(str string) int64 {
|
func Str2Int(str string) int64 {
|
||||||
val, _ := strconv.ParseInt(str, 10, 64)
|
val, _ := strconv.Atoi(str)
|
||||||
return val
|
return int64(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Int2Str int64 --> string
|
// Int2Str int64 --> string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user