mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 14:30:10 +08:00
✨ 优化代码结构
This commit is contained in:
parent
b7b9d92148
commit
3b7803a81b
@ -345,6 +345,8 @@ print("run[CQ:image,file="+j["img"]+"]")
|
|||||||
- [x] galCG[xxx]
|
- [x] galCG[xxx]
|
||||||
- [x] gal表情包[xxx]
|
- [x] gal表情包[xxx]
|
||||||
- [x] 更新gal
|
- [x] 更新gal
|
||||||
|
- **城市疫情查询** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/epidemic"`
|
||||||
|
- [x] xxx疫情
|
||||||
- **TODO...**
|
- **TODO...**
|
||||||
|
|
||||||
## 使用方法
|
## 使用方法
|
||||||
|
|||||||
1
main.go
1
main.go
@ -70,6 +70,7 @@ import (
|
|||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/diana" // 嘉心糖发病
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/drift_bottle" // 漂流瓶
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/emojimix" // 合成emoji
|
||||||
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/epidemic" // 城市疫情查询
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/fortune" // 运势
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/funny" // 笑话
|
||||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
|
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/gif" // 制图
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/FloatTech/zbputils/binary"
|
"github.com/FloatTech/zbputils/binary"
|
||||||
"github.com/FloatTech/zbputils/control"
|
"github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/control/order"
|
"github.com/FloatTech/zbputils/control/order"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,39 +48,36 @@ type area struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine := control.Register(servicename, order.AcquirePrio(), &control.Options{
|
engine := control.Register(servicename, order.AcquirePrio(), &control.Options{
|
||||||
DisableOnDefault: true,
|
DisableOnDefault: false,
|
||||||
Help: "本插件用于查询城市疫情状况\n" +
|
Help: "城市疫情查询\n" +
|
||||||
"使用方法列如: 北京疫情 \n",
|
"- xxx疫情\n",
|
||||||
})
|
})
|
||||||
engine.OnSuffix("疫情").SetBlock(true).
|
engine.OnSuffix("疫情").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
text := ctx.State["args"].(string)
|
city := ctx.State["args"].(string)
|
||||||
if text == "" {
|
if city == "" {
|
||||||
ctx.SendChain(message.Text("你还没有输入城市名字呢!"))
|
ctx.SendChain(message.Text("你还没有输入城市名字呢!"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, times, err := queryEpidemic(text)
|
data, time, err := queryEpidemic(city)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if data == nil {
|
if data == nil {
|
||||||
ctx.SendChain(message.Text("没有找到【", text, "】城市的疫情数据."))
|
ctx.SendChain(message.Text("没有找到【", city, "】城市的疫情数据."))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
process.SleepAbout1sTo2s()
|
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
message.Text(
|
message.Text(
|
||||||
"【", data.Name, "】疫情数据:\n",
|
"【", data.Name, "】疫情数据\n",
|
||||||
"新增:", data.Today.Confirm,
|
"新增:", data.Today.Confirm, " ,",
|
||||||
" ,现有确诊:", data.Total.NowConfirm,
|
"现有确诊:", data.Total.NowConfirm, " ,",
|
||||||
" ,治愈:", data.Total.Heal,
|
"治愈:", data.Total.Heal, " ,",
|
||||||
" ,死亡:", data.Total.Dead, " ", data.Total.Grade,
|
"死亡:", data.Total.Dead, " ", data.Total.Grade, "\n",
|
||||||
|
"更新时间:", time, "\n",
|
||||||
|
"温馨提示:请大家做好防疫工作,出门带好口罩!",
|
||||||
),
|
),
|
||||||
message.Text("\n"),
|
|
||||||
message.Text("更新时间:"+times),
|
|
||||||
message.Text("\n"),
|
|
||||||
message.Text("温馨提示:请大家做好防疫工作,出门带好口罩!"),
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user