refactor: 自动截取整页
This commit is contained in:
parent
2290146862
commit
9f5106663f
@ -15,7 +15,7 @@ func getweb(msg model.Message) (reply model.Reply) {
|
|||||||
return model.Reply{}
|
return model.Reply{}
|
||||||
}
|
}
|
||||||
url := msg.RawMsg[len("上网 "):]
|
url := msg.RawMsg[len("上网 "):]
|
||||||
if err := util.ScreenshotURL(url, "./tmp/getweb/url.png", 1920, 1080, 0, 0, 0, 0, ""); err != nil {
|
if err := util.ScreenshotURL(url, "./tmp/getweb/url.png", 0, 0, 0, 0, 0, 0, ""); err != nil {
|
||||||
return model.Reply{
|
return model.Reply{
|
||||||
ReplyMsg: err.Error(),
|
ReplyMsg: err.Error(),
|
||||||
ReferOriginMsg: true,
|
ReferOriginMsg: true,
|
||||||
|
@ -26,7 +26,14 @@ func plainTextUrlParser(msg model.Message) (reply model.Reply) {
|
|||||||
url = strings.Split(url, "\r")[0]
|
url = strings.Split(url, "\r")[0]
|
||||||
url = strings.Split(url, "\t")[0]
|
url = strings.Split(url, "\t")[0]
|
||||||
url, _ = removeTrackingParams(url)
|
url, _ = removeTrackingParams(url)
|
||||||
newUrl, _ := resolveFinalURL(url)
|
newUrl, err := resolveFinalURL(url)
|
||||||
|
if err != nil {
|
||||||
|
return model.Reply{
|
||||||
|
ReplyMsg: "",
|
||||||
|
ReferOriginMsg: false,
|
||||||
|
FromMsg: msg,
|
||||||
|
}
|
||||||
|
}
|
||||||
newUrl, _ = removeTrackingParams(newUrl)
|
newUrl, _ = removeTrackingParams(newUrl)
|
||||||
if util.IsEquivalentURL(url, newUrl) {
|
if util.IsEquivalentURL(url, newUrl) {
|
||||||
return model.Reply{
|
return model.Reply{
|
||||||
|
@ -16,10 +16,10 @@ func (c Command) ToString() string {
|
|||||||
if c.CommandName != "score" {
|
if c.CommandName != "score" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
strWithRank := "玩家 %s 使用 %s 在 %s 的 %s 难度(星级为%.1f)中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
strWithRank := "玩家 %s 使用 %s 在 %s 的 %s 难度(%.1f🌟)中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
||||||
strWithoutRank := "玩家 %s 使用 %s 在 %s 的 %s 难度中获得了 %d 分,排名第 %d。"
|
strWithoutRank := "玩家 %s 使用 %s 在 %s 的 %s 难度中获得了 %d 分,排名第 %d。"
|
||||||
strWithOutDevice := "玩家 %s 在 %s 的 %s 难度(星级为%.1f)中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
strWithOutDevice := "玩家 %s 在 %s 的 %s 难度(%.1f🌟)中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
||||||
strWithOutDeviceAndRank := "玩家 %s 在 %s 的 %s 难度(星级为%.1f)中获得了 %d 分。"
|
strWithOutDeviceAndRank := "玩家 %s 在 %s 的 %s 难度(%.1f🌟)中获得了 %d 分。"
|
||||||
hardStr := strings.Split(c.CommandData.Leaderboard.Difficulty.DifficultyRaw, "_")[1]
|
hardStr := strings.Split(c.CommandData.Leaderboard.Difficulty.DifficultyRaw, "_")[1]
|
||||||
if c.CommandData.Leaderboard.Ranked && c.CommandData.Score.DeviceHmd != nil {
|
if c.CommandData.Leaderboard.Ranked && c.CommandData.Score.DeviceHmd != nil {
|
||||||
return fmt.Sprintf(strWithRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, *c.CommandData.Score.DeviceHmd, c.CommandData.Leaderboard.SongName, hardStr, c.CommandData.Leaderboard.Stars, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank, c.CommandData.Score.Pp)
|
return fmt.Sprintf(strWithRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, *c.CommandData.Score.DeviceHmd, c.CommandData.Leaderboard.SongName, hardStr, c.CommandData.Leaderboard.Stars, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank, c.CommandData.Score.Pp)
|
||||||
@ -138,9 +138,9 @@ type RecordDataLite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r RecordDataLite) ToString() string {
|
func (r RecordDataLite) ToString() string {
|
||||||
formatedStrRanked := "%s,%s 使用 %s 在 %s 的 %s 难度(%.1f星级)中获得了 %d 分,pp 为 %.2f,准度为 %s。"
|
formatedStrRanked := "%s,%s 使用 %s 在 %s 的 %s 难度(%.1f🌟)中获得了 %d 分,pp 为 %.2f,准度为 %s。"
|
||||||
formatedStrUnranked := "%s, %s 使用 %s 在 %s 的 %s 难度中获得了 %d 分,准度为 %s。"
|
formatedStrUnranked := "%s, %s 使用 %s 在 %s 的 %s 难度中获得了 %d 分,准度为 %s。"
|
||||||
formatedStrWithoutDevice := "%s, %s 在 %s 的 %s 难度(%.1f星级)中获得了 %d 分,pp 为 %.2f,准度为 %s。"
|
formatedStrWithoutDevice := "%s, %s 在 %s 的 %s 难度(%.1f🌟)中获得了 %d 分,pp 为 %.2f,准度为 %s。"
|
||||||
formatedStrWithoutDeviceAndRank := "%s, %s 在 %s 的 %s 难度中获得了 %d 分,准度为 %s。"
|
formatedStrWithoutDeviceAndRank := "%s, %s 在 %s 的 %s 难度中获得了 %d 分,准度为 %s。"
|
||||||
hardStr := strings.Split(r.DifficultyRaw, "_")[1]
|
hardStr := strings.Split(r.DifficultyRaw, "_")[1]
|
||||||
layout := "2006-01-02 15:04:05.999999999-07:00"
|
layout := "2006-01-02 15:04:05.999999999-07:00"
|
||||||
|
@ -76,6 +76,11 @@ func ScreenshotURL(url, output string, width, height int, marginTop, marginBotto
|
|||||||
ignoreErrors(queryAction), // 等待指定元素
|
ignoreErrors(queryAction), // 等待指定元素
|
||||||
chromedp.Sleep(5*time.Second),
|
chromedp.Sleep(5*time.Second),
|
||||||
chromedp.ActionFunc(func(ctx context.Context) error { // 自定义截图逻辑
|
chromedp.ActionFunc(func(ctx context.Context) error { // 自定义截图逻辑
|
||||||
|
layoutViewport, _, _, _, _, _, _ := page.GetLayoutMetrics().Do(ctx)
|
||||||
|
if width == 0 || height == 0 {
|
||||||
|
width = int(layoutViewport.ClientWidth)
|
||||||
|
height = int(layoutViewport.ClientHeight)
|
||||||
|
}
|
||||||
// 计算调整后的截图区域
|
// 计算调整后的截图区域
|
||||||
clip := &page.Viewport{
|
clip := &page.Viewport{
|
||||||
X: float64(marginLeft),
|
X: float64(marginLeft),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user