Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化指令 #513

Merged
merged 24 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,9 @@ print("run[CQ:image,file="+j["img"]+"]")

###### `"github.com/FloatTech/ZeroBot-Plugin/plugin/ygo/ygotrade.go"`
- [x] 查卡价 [卡名]
- [x] 查卡价 [卡名] [稀有度 稀有度 ...]
- [x] 查卡价 [卡名] -r [稀有度 稀有度 ...]
- [x] 查卡店 [卡名]
- [x] 查卡店 [卡名] [稀有度]
- [x] 查卡店 [卡名] -r [稀有度]
- 注:卡店只支持单个稀有度查询

</details>
Expand Down
9 changes: 4 additions & 5 deletions plugin/ygo/ygotrade.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Package ygo 一些关于ygo的插件
package ygo


import (
"encoding/json"
"errors"
Expand Down Expand Up @@ -49,14 +48,14 @@ type tradeInfo struct {
func init() {
engine := control.Register("ygotrade", &ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
Brief: "游戏王卡价查询",// 本插件基于集换社API
Help: "- 查卡价 [卡名]\n- 查卡价 [卡名] [稀有度 稀有度 ...]\n- 查卡店 [卡名]\n- 查卡店 [卡名] [稀有度]",
Brief: "游戏王卡价查询", // 本插件基于集换社API
Help: "- 查卡价 [卡名]\n- 查卡价 [卡名] -r [稀有度 稀有度 ...]\n- 查卡店 [卡名]\n- 查卡店 [卡名] -r [稀有度]",
}).ApplySingle(ctxext.DefaultSingle)
engine.OnPrefix("查卡价", func(ctx *zero.Ctx) bool {
ctx.State["args"] = strings.TrimSpace(ctx.State["args"].(string))
return ctx.State["args"].(string) != ""
}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
cardName, rarity, _ := strings.Cut(ctx.State["args"].(string), " ")
cardName, rarity, _ := strings.Cut(ctx.State["args"].(string), " -r ")
listOfTrace, err := getRarityTrade(cardName, rarity)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
Expand All @@ -80,7 +79,7 @@ func init() {
ctx.State["args"] = strings.TrimSpace(ctx.State["args"].(string))
return ctx.State["args"].(string) != ""
}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
cardName, rarity, _ := strings.Cut(ctx.State["args"].(string), " ")
cardName, rarity, _ := strings.Cut(ctx.State["args"].(string), " -r ")
if strings.Count(rarity, " ") > 0 {
ctx.SendChain(message.Text("ERROR: ", "卡店查询不支持查找多个罕贵度"))
return
Expand Down