feat: 添加查bll 和 查sss 命令,支持仅获取第一帧图像
This commit is contained in:
parent
de5af61acf
commit
627d319911
@ -20,6 +20,8 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("查bl", getMyBLPic, constants.LEVEL_USER)
|
handler.RegisterHandler("查bl", getMyBLPic, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("查bl", "beatleader", "查bl 查看您的最新分数")
|
handler.RegisterHelpInform("查bl", "beatleader", "查bl 查看您的最新分数")
|
||||||
|
handler.RegisterHandler("查bll", getMyBLPic, constants.LEVEL_USER)
|
||||||
|
handler.RegisterHelpInform("查bll", "beatleader", "查bll 查看您的最新分数(仅取第一帧)")
|
||||||
handler.RegisterHandler("绑定bl", bindBL, constants.LEVEL_USER)
|
handler.RegisterHandler("绑定bl", bindBL, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("绑定bl", "beatleader", "绑定bl 绑定您的beatleader账号")
|
handler.RegisterHelpInform("绑定bl", "beatleader", "绑定bl 绑定您的beatleader账号")
|
||||||
handler.RegisterHandler("解绑bl", unbindBL, constants.LEVEL_USER)
|
handler.RegisterHandler("解绑bl", unbindBL, constants.LEVEL_USER)
|
||||||
@ -174,6 +176,11 @@ func getMyBLPic(msg model.Message) (reply *model.Reply) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
tokens := util.SplitN(msg.RawMsg, 2)
|
tokens := util.SplitN(msg.RawMsg, 2)
|
||||||
|
|
||||||
|
onlyFirstFrame := false
|
||||||
|
if strings.HasPrefix(msg.RawMsg, "查bll") {
|
||||||
|
onlyFirstFrame = true
|
||||||
|
}
|
||||||
var userIdStr string
|
var userIdStr string
|
||||||
var noUpdate bool = false
|
var noUpdate bool = false
|
||||||
if len(tokens) == 2 {
|
if len(tokens) == 2 {
|
||||||
@ -207,9 +214,9 @@ func getMyBLPic(msg model.Message) (reply *model.Reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if lastData != nil {
|
if lastData != nil {
|
||||||
resultStr = data.LastDiffToImage(*lastData)
|
resultStr = data.LastDiffToImage(*lastData, onlyFirstFrame)
|
||||||
} else {
|
} else {
|
||||||
resultStr = data.LastDiffToImage(*data)
|
resultStr = data.LastDiffToImage(*data, onlyFirstFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
imageMsg := message.ImageMessage{
|
imageMsg := message.ImageMessage{
|
||||||
|
@ -19,6 +19,8 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("查ss", getMySSPic, constants.LEVEL_USER)
|
handler.RegisterHandler("查ss", getMySSPic, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("查ss", "scoresaber", " 查看您的最新分数")
|
handler.RegisterHelpInform("查ss", "scoresaber", " 查看您的最新分数")
|
||||||
|
handler.RegisterHandler("查sss", getMySSPic, constants.LEVEL_USER)
|
||||||
|
handler.RegisterHelpInform("查sss", "scoresaber", "查sss 查看您的最新分数(仅取第一帧)")
|
||||||
handler.RegisterHandler("绑定ss", bindSS, constants.LEVEL_USER)
|
handler.RegisterHandler("绑定ss", bindSS, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("绑定ss", "scoresaber", "绑定您的scoresaber账号")
|
handler.RegisterHelpInform("绑定ss", "scoresaber", "绑定您的scoresaber账号")
|
||||||
handler.RegisterHandler("解绑ss", unbindSS, constants.LEVEL_USER)
|
handler.RegisterHandler("解绑ss", unbindSS, constants.LEVEL_USER)
|
||||||
@ -164,6 +166,10 @@ func ssPlusN(msg model.Message) (reply *model.Reply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getMySSPic(msg model.Message) (reply *model.Reply) {
|
func getMySSPic(msg model.Message) (reply *model.Reply) {
|
||||||
|
onlyFirstFrame := false
|
||||||
|
if strings.HasPrefix(msg.RawMsg, "查sss") {
|
||||||
|
onlyFirstFrame = true
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
resultStr string
|
resultStr string
|
||||||
err error
|
err error
|
||||||
@ -203,9 +209,9 @@ func getMySSPic(msg model.Message) (reply *model.Reply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if lastData != nil {
|
if lastData != nil {
|
||||||
resultStr = data.LastDiffToImage(*lastData)
|
resultStr = data.LastDiffToImage(*lastData, onlyFirstFrame)
|
||||||
} else {
|
} else {
|
||||||
resultStr = data.LastDiffToImage(*data)
|
resultStr = data.LastDiffToImage(*data, onlyFirstFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
imageMsg := message.ImageMessage{
|
imageMsg := message.ImageMessage{
|
||||||
|
@ -505,7 +505,7 @@ func (p PlayerDataLite) LastDiffToString(lastQueryData PlayerDataLite) string {
|
|||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p PlayerDataLite) LastDiffToImage(lastQueryData PlayerDataLite) string {
|
func (p PlayerDataLite) LastDiffToImage(lastQueryData PlayerDataLite, onlyFirstFrame bool) string {
|
||||||
filePath, err := util.DownloadFile(p.Avatar, "/tmp/qqbot", false)
|
filePath, err := util.DownloadFile(p.Avatar, "/tmp/qqbot", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Default().Printf("下载头像失败,url:%s,err:%v", p.Avatar, err)
|
log.Default().Printf("下载头像失败,url:%s,err:%v", p.Avatar, err)
|
||||||
@ -607,7 +607,7 @@ func (p PlayerDataLite) LastDiffToImage(lastQueryData PlayerDataLite) string {
|
|||||||
Position: image.Point{X: minX - 5, Y: minY - 5},
|
Position: image.Point{X: minX - 5, Y: minY - 5},
|
||||||
}
|
}
|
||||||
baseboard.AddSprite(&backgroundSpirit)
|
baseboard.AddSprite(&backgroundSpirit)
|
||||||
if len(avatarSpirit.Images) > 1 {
|
if len(avatarSpirit.Images) > 1 && !onlyFirstFrame {
|
||||||
if err := baseboard.SaveToGif(util.GenTempFilePath("cbl.gif")); err != nil {
|
if err := baseboard.SaveToGif(util.GenTempFilePath("cbl.gif")); err != nil {
|
||||||
log.Default().Printf("保存图片失败,err:%v", err)
|
log.Default().Printf("保存图片失败,err:%v", err)
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ func (p PlayerData) LastDiffToString(lastDayQueryData PlayerDataLite) string {
|
|||||||
p.ScoreStats.ReplaysWatched)
|
p.ScoreStats.ReplaysWatched)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p PlayerDataLite) LastDiffToImage(lastQueryData PlayerDataLite) string {
|
func (p PlayerDataLite) LastDiffToImage(lastQueryData PlayerDataLite, onlyFirstFrame bool) string {
|
||||||
filePath, err := util.DownloadFile(p.ProfilePicture, "/tmp/qqbot", false)
|
filePath, err := util.DownloadFile(p.ProfilePicture, "/tmp/qqbot", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Default().Printf("下载头像失败,url:%s,err:%v", p.ProfilePicture, err)
|
log.Default().Printf("下载头像失败,url:%s,err:%v", p.ProfilePicture, err)
|
||||||
@ -426,7 +426,7 @@ func (p PlayerDataLite) LastDiffToImage(lastQueryData PlayerDataLite) string {
|
|||||||
Position: image.Point{X: minX - 5, Y: minY - 5},
|
Position: image.Point{X: minX - 5, Y: minY - 5},
|
||||||
}
|
}
|
||||||
baseboard.AddSprite(&backgroundSpirit)
|
baseboard.AddSprite(&backgroundSpirit)
|
||||||
if len(avatarSpirit.Images) > 1 {
|
if len(avatarSpirit.Images) > 1 && !onlyFirstFrame {
|
||||||
if err := baseboard.SaveToGif(util.GenTempFilePath("css.gif")); err != nil {
|
if err := baseboard.SaveToGif(util.GenTempFilePath("css.gif")); err != nil {
|
||||||
log.Default().Printf("保存图片失败,err:%v", err)
|
log.Default().Printf("保存图片失败,err:%v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user