mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
独立wallet插件 (#531)
This commit is contained in:
@@ -54,11 +54,6 @@ func init() {
|
||||
}
|
||||
sdb = initialize(engine.DataFolder() + "score.db")
|
||||
}()
|
||||
zero.OnFullMatch("查看我的钱包").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
money := wallet.GetWalletOf(uid)
|
||||
ctx.SendChain(message.At(uid), message.Text("你的钱包当前有", money, "ATRI币"))
|
||||
})
|
||||
engine.OnFullMatch("签到").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
@@ -275,88 +270,6 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
engine.OnFullMatch("查看钱包排名", zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := strconv.FormatInt(ctx.Event.GroupID, 10)
|
||||
today := time.Now().Format("20060102")
|
||||
drawedFile := cachePath + gid + today + "walletRank.png"
|
||||
if file.IsExist(drawedFile) {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
return
|
||||
}
|
||||
// 无缓存获取群员列表
|
||||
temp := ctx.GetThisGroupMemberListNoCache().Array()
|
||||
usergroup := make([]int64, len(temp))
|
||||
for i, info := range temp {
|
||||
usergroup[i] = info.Get("user_id").Int()
|
||||
}
|
||||
// 获取钱包信息
|
||||
st, err := wallet.GetGroupWalletOf(true, usergroup...)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(st) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 当前没人获取过ATRI币"))
|
||||
return
|
||||
} else if len(st) > 10 {
|
||||
st = st[:10]
|
||||
}
|
||||
_, err = file.GetLazyData(text.FontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
b, err := os.ReadFile(text.FontFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
font, err := freetype.ParseFont(b)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var bars []chart.Value
|
||||
for _, v := range st {
|
||||
if v.Money != 0 {
|
||||
bars = append(bars, chart.Value{
|
||||
Label: ctx.CardOrNickName(v.UID),
|
||||
Value: float64(v.Money),
|
||||
})
|
||||
}
|
||||
}
|
||||
err = chart.BarChart{
|
||||
Font: font,
|
||||
Title: "ATRI币排名(1天只刷新1次)",
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{
|
||||
Top: 40,
|
||||
},
|
||||
},
|
||||
YAxis: chart.YAxis{
|
||||
Range: &chart.ContinuousRange{
|
||||
Min: 0,
|
||||
Max: math.Ceil(bars[0].Value/10) * 10,
|
||||
},
|
||||
},
|
||||
Height: 500,
|
||||
BarWidth: 50,
|
||||
Bars: bars,
|
||||
}.Render(chart.PNG, f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
_ = os.Remove(drawedFile)
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
}
|
||||
|
||||
func getHourWord(t time.Time) string {
|
||||
|
||||
Reference in New Issue
Block a user