fix
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user