fix: add logging for fetching telegraph page and handle image URLs from telegra.ph

This commit is contained in:
krau
2025-10-06 22:13:41 +08:00
parent 76a82a38ee
commit 0e989cc1a6
2 changed files with 6 additions and 0 deletions

View File

@@ -196,6 +196,7 @@ func GetTphPicsFromMessageWithReply(ctx *ext.Context, update *ext.Update) (*type
logger.Errorf("Failed to reply to update: %s", err)
return nil, nil, dispatcher.EndGroups
}
logger.Debugf("Fetching telegraph page: %s", pagepath)
page, err := tphutil.DefaultClient().GetPage(ctx, pagepath)
if err != nil {
logger.Errorf("Failed to get telegraph page: %s", err)

View File

@@ -2,6 +2,7 @@ package tphutil
import (
"encoding/json"
"strings"
"github.com/krau/SaveAny-Bot/config"
"github.com/krau/SaveAny-Bot/pkg/telegraph"
@@ -41,6 +42,10 @@ func GetNodeImages(node telegraph.Node) []string {
if nodeElement.Tag == "img" {
if src, exists := nodeElement.Attrs["src"]; exists {
if strings.HasPrefix(src, "/file/") {
// handle images on telegra.ph server
src = "https://telegra.ph" + src
}
srcs = append(srcs, src)
}
}