feat: 添加截图功能

This commit is contained in:
lixiangwuxian 2024-10-13 04:54:49 +08:00
parent ffb5ff8af8
commit 056767b4f0
2 changed files with 30 additions and 2 deletions

View File

@ -15,6 +15,7 @@ func init() {
handler.RegisterHandler("解绑ss", unbindSS)
handler.RegisterHandler("最新ss", getMyRecentScore)
handler.RegisterHandler("最热ss", getRecentScore)
handler.RegisterHandler("截图ss", screenshotSS)
}
func getMySS(msg model.Message) (reply model.Reply) {
@ -134,3 +135,11 @@ func getMyRecentScore(msg model.Message) (reply model.Reply) {
FromMsg: msg,
}
}
func screenshotSS(msg model.Message) (reply model.Reply) {
return model.Reply{
ReplyMsg: "[CQ:image,file=file:///root/qqbot/tmp/" + scoresaber.GetSSPicture(strconv.Itoa(int(msg.UserId))) + "]",
ReferOriginMsg: true,
FromMsg: msg,
}
}

View File

@ -1,5 +1,24 @@
package scoresaber
func (data *PlayerData) ToPicture() (outputImgPath string) {
return ""
import (
"fmt"
"git.lxtend.com/qqbot/util"
)
func GetSSPicture(qqId string) (outputImgName string) {
ssId, err := getSSID(qqId)
if err != nil {
return ""
}
url := fmt.Sprintf("https://scoresaber.com/u/%s", ssId)
// url := fmt.Sprintf("https://scoresaber.com/rankings")
outputImgPath := fmt.Sprintf("./tmp/scoresaber_%s.png", ssId)
outputImgName = fmt.Sprintf("scoresaber_%s.png", ssId)
if err := util.ScreenshotURL(url, outputImgPath, 1620, 3080, 60, 0, 300, 300, "ranking songs"); err != nil {
fmt.Println(err)
return ""
}
return outputImgName
}