mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 15:20:22 +00:00
qqwife新增好感度列表功能 (#504)
This commit is contained in:
@@ -648,6 +648,77 @@ func init() {
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
})
|
||||
engine.OnFullMatch("好感度列表", zero.OnlyGroup, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
uid := ctx.Event.UserID
|
||||
fianceeInfo, err := 民政局.getGroupFavorability(uid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
/***********设置图片的大小和底色***********/
|
||||
number := len(fianceeInfo)
|
||||
if number > 10 {
|
||||
number = 10
|
||||
}
|
||||
fontSize := 50.0
|
||||
canvas := gg.NewContext(1150, int(170+(50+70)*float64(number)))
|
||||
canvas.SetRGB(1, 1, 1) // 白色
|
||||
canvas.Clear()
|
||||
/***********下载字体***********/
|
||||
_, err = file.GetLazyData(text.BoldFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
}
|
||||
/***********设置字体颜色为黑色***********/
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize*2); err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sl, h := canvas.MeasureString("你的好感度排行列表")
|
||||
/***********绘制标题***********/
|
||||
canvas.DrawString("你的好感度排行列表", (1100-sl)/2, 100) // 放置在中间位置
|
||||
canvas.DrawString("————————————————————", 0, 160)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
i := 0
|
||||
for _, info := range fianceeInfo {
|
||||
if i > 9 {
|
||||
break
|
||||
}
|
||||
if info.Userinfo == "" {
|
||||
continue
|
||||
}
|
||||
fianceID, err := strconv.ParseInt(info.Userinfo, 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[qqwife]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if fianceID == 0 {
|
||||
continue
|
||||
}
|
||||
userName := ctx.CardOrNickName(fianceID)
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawString(userName+"("+info.Userinfo+")", 10, float64(180+(50+70)*i))
|
||||
canvas.DrawString(strconv.Itoa(info.Favor), 1020, float64(180+60+(50+70)*i))
|
||||
canvas.DrawRectangle(10, float64(180+60+(50+70)*i)-h/2, 1000, 50)
|
||||
canvas.SetRGB255(150, 150, 150)
|
||||
canvas.Fill()
|
||||
canvas.SetRGB255(0, 0, 0)
|
||||
canvas.DrawRectangle(10, float64(180+60+(50+70)*i)-h/2, float64(info.Favor)*10, 50)
|
||||
canvas.SetRGB255(231, 27, 100)
|
||||
canvas.Fill()
|
||||
i++
|
||||
}
|
||||
data, cl := writer.ToBytes(canvas.Image())
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
})
|
||||
engine.OnRegex(`^重置(所有|本群|/d+)?花名册$`, zero.SuperUserPermission, getdb).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
cmd := "0"
|
||||
|
||||
Reference in New Issue
Block a user