This commit is contained in:
Rogee
2024-09-02 19:51:29 +08:00
parent 399dbe4264
commit 422a5a9cab
3 changed files with 19 additions and 3 deletions

4
.vscode/launch.json vendored
View File

@@ -23,7 +23,9 @@
// https://t.me/meizitu3/6879 // https://t.me/meizitu3/6879
// "--alias", "meizitu3", // "--alias", "meizitu3",
// https://t.me/DNSPODT/5156 // https://t.me/DNSPODT/5156
"--alias", "DNSPODT", // "--alias", "DNSPODT",
// https://t.me/ruyoblog/4247
"--alias", "ruyoblog",
"--history", "--history",
] ]
} }

View File

@@ -17,6 +17,12 @@ type ChannelMessage struct {
type ChannelMessageMedia struct { type ChannelMessageMedia struct {
Photo string Photo string
Video string Video string
WebPage ChannelMessageMediaWebPage
}
type ChannelMessageMediaWebPage struct {
Title string
URL string
} }
func NewChannelMessage(id, ts int) *ChannelMessage { func NewChannelMessage(id, ts int) *ChannelMessage {
@@ -43,6 +49,11 @@ func (c *ChannelMessage) WithVideo(video string) *ChannelMessage {
return c return c
} }
func (c *ChannelMessage) WithWebPage(title, url string) *ChannelMessage {
c.Medias = append(c.Medias, ChannelMessageMedia{WebPage: ChannelMessageMediaWebPage{Title: title, URL: url}})
return c
}
func (c *ChannelMessage) GetMedia() string { func (c *ChannelMessage) GetMedia() string {
b, _ := json.Marshal(c.Medias) b, _ := json.Marshal(c.Medias)
return string(b) return string(b)

View File

@@ -72,6 +72,9 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
return return
case *tg.MessageMediaWebPage: case *tg.MessageMediaWebPage:
t.logger.Warn("web_page", zap.String("url", mediaClass.(*tg.MessageMediaWebPage).GetWebpage().String())) t.logger.Warn("web_page", zap.String("url", mediaClass.(*tg.MessageMediaWebPage).GetWebpage().String()))
if page, ok := mediaClass.(*tg.MessageMediaWebPage).GetWebpage().(*tg.WebPage); ok {
channelMessage.WithWebPage(page.Title, page.URL)
}
return return
case *tg.MessageMediaPhoto: case *tg.MessageMediaPhoto:
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok { if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {