Skip to content

Commit

Permalink
Merge remote-tracking branch 'upsteram/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiang-Red committed Mar 24, 2023
2 parents fdf6ef2 + d693f98 commit 715cc8f
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 72 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ print("run[CQ:image,file="+j["img"]+"]")

</details>
<details>
<summary>百度一下</summary>
<summary>百度百科</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu"`

- [x] 百度下[xxx]
- [x] 百度/百科[xxx]

</details>
<details>
Expand Down Expand Up @@ -559,7 +559,7 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] b站推送列表

- [x] 拉取b站推送 (使用job执行定时任务------记录在"@every 10s"触发的指令)
- [x] 拉取b站推送 (使用job执行定时任务------记录在"@every 5m"触发的指令)

</details>
<details>
Expand Down Expand Up @@ -1283,6 +1283,22 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 黄油角色[@xxx]

</details>
<details>
<summary>steam</summary>

`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam"`

- [x] steam[添加|删除]订阅xxxxx

- [x] steam查看订阅

- [x] steam绑定 api key xxxxxxx

- [x] 查看apikey

- [x] 拉取steam订阅 (使用job执行定时任务------记录在"@every 1m"触发的指令)

</details>
<details>
<summary>抽塔罗牌</summary>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/FloatTech/AnimeAPI v1.6.1-0.20230316111643-46d40c9d80e3
github.com/FloatTech/floatbox v0.0.0-20230316111222-7ffde57284cc
github.com/FloatTech/gg v1.1.2
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9
github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9
github.com/FloatTech/sqlite v1.5.7
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/FloatTech/gg v1.1.2 h1:YolgOYg3uDHc1+g0bLtt6QuRA/pvLn+b9IBCIhOOX88=
github.com/FloatTech/gg v1.1.2/go.mod h1:uzPzAeT35egARdRuu+1oyjU3CmTwCceoq3Vvje7LpcI=
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9 h1:IzZLuM/fgKclyMaU/Qb1qlLdGrs2FTietkqOWhh07Gw=
github.com/FloatTech/imgfactory v0.2.2-0.20230315152233-49741fc994f9/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b h1:VMNci4SWBySdw/6poqF9Dn9zlT5ntTFSJOEEBjRnJ/4=
github.com/FloatTech/imgfactory v0.2.2-0.20230322091809-b0ddbe44b94b/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9 h1:hffajvmQFfP68U6wUwHemPuuwCUoss+SEFfoLYwbGwE=
github.com/FloatTech/rendercard v0.0.10-0.20230223064326-45d29fa4ede9/go.mod h1:NBFPhWae4hqVMeG8ELBBnUQkKce3nDjkljVn6PdiUNs=
github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk=
Expand Down
4 changes: 2 additions & 2 deletions kanban/banner/banner.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ import (
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/setutime" // 来份涩图
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shadiao" // 沙雕app
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/shindan" // 测定
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/steam" // steam相关
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tarot" // 抽塔罗牌
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou" // 舔狗日记
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/tracemoe" // 搜番
Expand Down Expand Up @@ -249,13 +250,12 @@ func init() {
fmt.Println("Usage:")
flag.PrintDefaults()
os.Exit(0)
} else {
if *d && !*w {
logrus.SetLevel(logrus.DebugLevel)
}
if *w {
logrus.SetLevel(logrus.WarnLevel)
}
}
if *d && !*w {
logrus.SetLevel(logrus.DebugLevel)
}
if *w {
logrus.SetLevel(logrus.WarnLevel)
}

for _, s := range flag.Args() {
Expand Down
2 changes: 1 addition & 1 deletion plugin/atri/atri.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func randText(text ...string) message.MessageSegment {
}

// isAtriSleeping 凌晨0点到6点,ATRI 在睡觉,不回应任何请求
func isAtriSleeping(ctx *zero.Ctx) bool {
func isAtriSleeping(*zero.Ctx) bool {
if now := time.Now().Hour(); now >= 1 && now < 6 {
return true
}
Expand Down
56 changes: 40 additions & 16 deletions plugin/baidu/search.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
// Package baidu 百度一下
// Package baidu 百度百科
package baidu

import (
"net/url"
"encoding/json"
"fmt"

"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)

ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
const (
api = "https://api.a20safe.com/api.php?api=21&key=7d06a110e9e20a684e02934549db1d3d&text=%s" // api地址
)

func init() {
control.Register("baidu", &ctrl.Options[*zero.Ctx]{
type result struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data []struct {
Content string `json:"content"`
} `json:"data"`
}

func init() { // 主函数
en := control.Register("baidu", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "不会百度吗",
Help: "- 百度下[xxx]",
}).OnPrefix("百度下").SetBlock(true).Limit(ctxext.LimitByGroup).
Handle(func(ctx *zero.Ctx) {
txt := ctx.State["args"].(string)
if txt != "" {
ctx.SendChain(message.Text("https://buhuibaidu.me/?s=" + url.QueryEscape(txt)))
}
})
Help: "百度百科\n" +
"- 百度/百科[关键字]",
})
en.OnRegex(`^百[度科]\s*(.+)$`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
es, err := web.GetData(fmt.Sprintf(api, ctx.State["regex_matched"].([]string)[1])) // 将网站返回结果赋值
if err != nil {
ctx.SendChain(message.Text("出现错误捏:", err))
return
}
var r result // r数组
err = json.Unmarshal(es, &r) // 填api返回结果,struct地址
if err != nil {
ctx.SendChain(message.Text("出现错误捏:", err))
return
}
if r.Code == 0 && len(r.Data) > 0 {
ctx.SendChain(message.Text(r.Data[0].Content)) // 输出提取后的结果
} else {
ctx.SendChain(message.Text("API访问错误"))
}
})
}
4 changes: 2 additions & 2 deletions plugin/drawlots/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ func randGif(gifName string) (image.Image, error) {
return nil, err
}
v := im.Image[rand.Intn(len(im.Image))]
return imgfactory.Size(firstImg, firstImg.Bounds().Max.X, firstImg.Bounds().Max.Y).InsertUpC(v, 0, 0, firstImg.Bounds().Max.X/2, firstImg.Bounds().Max.Y/2).Clone().Image(),err
return imgfactory.Size(firstImg, firstImg.Bounds().Dx(), firstImg.Bounds().Dy()).InsertUpC(v, 0, 0, firstImg.Bounds().Dx()/2, firstImg.Bounds().Dy()/2).Clone().Image(),err
/*/
// 如果gif图片出现信息缺失请使用上面注释掉的代码,把下面注释了(上面代码部分图存在bug)
v := im.Image[rand.Intn(len(im.Image))]
return imgfactory.NewFactoryBG(v.Rect.Max.X, v.Rect.Max.Y, color.NRGBA{0, 0, 0, 255}).InsertUp(v, 0, 0, 0, 0).Clone().Image(), err
return imgfactory.NewFactoryBG(v.Rect.Dx(), v.Rect.Dy(), color.NRGBA{0, 0, 0, 255}).InsertUp(v, 0, 0, 0, 0).Clone().Image(), err
// */
}
4 changes: 2 additions & 2 deletions plugin/gif/gif.go
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ func alwaysDoGif(cc *context, value ...string) (string, error) {
var err error
var face []*imgfactory.Factory
name := cc.usrdir + "AlwaysDo.gif"
face, err = imgfactory.LoadAllFrames(cc.headimgsdir[0], 500, 500)
face, err = imgfactory.LoadAllTrueFrames(cc.headimgsdir[0], 500, 500)
if err != nil {
// 载入失败尝试载入第一帧
face = nil
Expand Down Expand Up @@ -1438,7 +1438,7 @@ func alwaysDoGif(cc *context, value ...string) (string, error) {
canvas := gg.NewContext(500, 600)
canvas.DrawImage(f.Image(), 0, 0)
canvas.SetColor(color.Black)
// _ = canvas.ParseFontFace(data, 40)
_ = canvas.ParseFontFace(data, 40)
canvas.DrawString(arg, 280-l, 560)
canvas.DrawImage(imgfactory.Size(f.Image(), 90, 90).Image(), 280, 505)
canvas.DrawString("吗", 370, 560)
Expand Down
4 changes: 2 additions & 2 deletions plugin/jiami/jiami.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

const (
jiami1 = "http://ovooa.com/API/sho_u/?msg=%v" // 加密api地址
jiami2 = "http://ovooa.com/API/sho_u/?format=1&msg=%v" // 解密api地址
jiami1 = "http://ovooa.caonm.net/API/sho_u/?msg=%v" // 加密api地址
jiami2 = "http://ovooa.caonm.net/API/sho_u/?format=1&msg=%v" // 解密api地址

)

Expand Down
38 changes: 19 additions & 19 deletions plugin/saucenao/searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,27 +162,27 @@ func init() { // 插件主体
ctx.SendChain(message.Text("请私聊发送 设置 saucenao api key [apikey] 以启用 saucenao 搜图 (方括号不需要输入), key 请前往 https://saucenao.com/user.php?page=search-api 获取"))
}
// ascii2d 搜索
if result, err := ascii2d.ASCII2d(pic); err != nil {
result, err := ascii2d.ASCII2d(pic)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
continue
} else {
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 id := ctx.Send(msg).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
}
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 id := ctx.Send(msg).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
}
}
})
Expand Down
5 changes: 1 addition & 4 deletions plugin/setutime/setu_geter.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
return err
}
// 添加插画到对应的数据库table
if err := p.db.Insert(imgtype, illust); err != nil {
return err
}
return nil
return p.db.Insert(imgtype, illust)
}

func (p *imgpool) remove(imgtype string, id int64) error {
Expand Down
4 changes: 2 additions & 2 deletions plugin/sleep_manage/sleep_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ func timeDuration(time time.Duration) (hour, minute, second int64) {
}

// 只统计6点到12点的早安
func isMorning(ctx *zero.Ctx) bool {
func isMorning(*zero.Ctx) bool {
now := time.Now().Hour()
return now >= 6 && now <= 12
}

// 只统计21点到凌晨3点的晚安
func isEvening(ctx *zero.Ctx) bool {
func isEvening(*zero.Ctx) bool {
now := time.Now().Hour()
return now >= 21 || now <= 3
}
4 changes: 0 additions & 4 deletions plugin/steam/listenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/FloatTech/floatbox/binary"
"github.com/FloatTech/floatbox/web"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
Expand Down Expand Up @@ -116,14 +115,12 @@ func getPlayerStatus(streamIds ...string) ([]*player, error) {
players := make([]*player, 0)
// 拼接请求地址
url := fmt.Sprintf(URL+StatusURL, apiKey, strings.Join(streamIds, ","))
logrus.Debugln("[steamstatus] getPlayerStatus url:", url)
// 拉取并解析数据
data, err := web.GetData(url)
if err != nil {
return players, err
}
dataStr := binary.BytesToString(data)
logrus.Debugln("[steamstatus] getPlayerStatus data:", dataStr)
index := gjson.Get(dataStr, "response.players.#").Uint()
for i := uint64(0); i < index; i++ {
players = append(players, &player{
Expand All @@ -133,6 +130,5 @@ func getPlayerStatus(streamIds ...string) ([]*player, error) {
GameExtraInfo: gjson.Get(dataStr, fmt.Sprintf("response.players.%d.gameextrainfo", i)).String(),
})
}
logrus.Debugln("[steamstatus] getPlayerStatus players:", players)
return players, nil
}
2 changes: 1 addition & 1 deletion plugin/steam/steam.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
"- steam删除订阅 xxxxxxx (删除你创建的对于 steamid 的绑定)\n" +
"- steam查询订阅 (查询本群内所有的绑定对象)\n" +
"-----------------------\n" +
"- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/registerkey)\n" +
"- steam绑定 api key xxxxxxx (密钥在steam网站申请, 申请地址: https://steamcommunity.com/dev/apikey)\n" +
"- 查看apikey (查询已经绑定的密钥)\n" +
"- 拉取steam订阅 (使用插件定时任务开始)\n" +
"-----------------------\n" +
Expand Down
12 changes: 6 additions & 6 deletions winres/winres.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"0409": {
"identity": {
"name": "ZeroBot-Plugin",
"version": "1.7.0.1749"
"version": "1.7.0.1760"
},
"description": "",
"minimum-os": "vista",
Expand All @@ -36,23 +36,23 @@
"#1": {
"0000": {
"fixed": {
"file_version": "1.7.0.1749",
"product_version": "v1.7.0-beta5",
"timestamp": "2023-03-16T19:22:18+08:00"
"file_version": "1.7.0.1760",
"product_version": "v1.7.0",
"timestamp": "2023-03-20T12:28:01+08:00"
},
"info": {
"0409": {
"Comments": "OneBot plugins based on ZeroBot",
"CompanyName": "FloatTech",
"FileDescription": "https://github.com/FloatTech/ZeroBot-Plugin",
"FileVersion": "1.7.0.1749",
"FileVersion": "1.7.0.1760",
"InternalName": "",
"LegalCopyright": "© 2020 - 2023 FloatTech. All Rights Reserved.",
"LegalTrademarks": "",
"OriginalFilename": "ZBP.EXE",
"PrivateBuild": "",
"ProductName": "ZeroBot-Plugin",
"ProductVersion": "v1.7.0-beta5",
"ProductVersion": "v1.7.0",
"SpecialBuild": ""
}
}
Expand Down

0 comments on commit 715cc8f

Please sign in to comment.