feat: 添加截图功能
This commit is contained in:
parent
ffb5ff8af8
commit
056767b4f0
@ -15,6 +15,7 @@ func init() {
|
|||||||
handler.RegisterHandler("解绑ss", unbindSS)
|
handler.RegisterHandler("解绑ss", unbindSS)
|
||||||
handler.RegisterHandler("最新ss", getMyRecentScore)
|
handler.RegisterHandler("最新ss", getMyRecentScore)
|
||||||
handler.RegisterHandler("最热ss", getRecentScore)
|
handler.RegisterHandler("最热ss", getRecentScore)
|
||||||
|
handler.RegisterHandler("截图ss", screenshotSS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMySS(msg model.Message) (reply model.Reply) {
|
func getMySS(msg model.Message) (reply model.Reply) {
|
||||||
@ -134,3 +135,11 @@ func getMyRecentScore(msg model.Message) (reply model.Reply) {
|
|||||||
FromMsg: msg,
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,24 @@
|
|||||||
package scoresaber
|
package scoresaber
|
||||||
|
|
||||||
func (data *PlayerData) ToPicture() (outputImgPath string) {
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.lxtend.com/qqbot/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetSSPicture(qqId string) (outputImgName string) {
|
||||||
|
ssId, err := getSSID(qqId)
|
||||||
|
if err != nil {
|
||||||
return ""
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user