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

View File

@@ -15,8 +15,14 @@ type ChannelMessage struct {
}
type ChannelMessageMedia struct {
Photo string
Video string
Photo string
Video string
WebPage ChannelMessageMediaWebPage
}
type ChannelMessageMediaWebPage struct {
Title string
URL string
}
func NewChannelMessage(id, ts int) *ChannelMessage {
@@ -43,6 +49,11 @@ func (c *ChannelMessage) WithVideo(video string) *ChannelMessage {
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 {
b, _ := json.Marshal(c.Medias)
return string(b)

View File

@@ -72,6 +72,9 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
return
case *tg.MessageMediaWebPage:
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
case *tg.MessageMediaPhoto:
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {