fix: issues
3
.gitignore
vendored
@@ -25,4 +25,5 @@ go.work
|
|||||||
log.json
|
log.json
|
||||||
log-*.json
|
log-*.json
|
||||||
session.json
|
session.json
|
||||||
tdl-export.json
|
tdl-export.json
|
||||||
|
./exporter
|
||||||
@@ -34,7 +34,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
return errors.Wrap(err, "messages.getHistory")
|
return errors.Wrap(err, "messages.getHistory")
|
||||||
}
|
}
|
||||||
if len(messages.(*tg.MessagesChannelMessages).GetMessages()) == 0 {
|
if len(messages.(*tg.MessagesChannelMessages).GetMessages()) == 0 {
|
||||||
logger.Info("no new message")
|
logger.Info("no new message", zap.Int64("channel", channel.ID))
|
||||||
return errors.New("no new message")
|
return errors.New("no new message")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
|
|
||||||
msg, ok := item.(*tg.Message)
|
msg, ok := item.(*tg.Message)
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.Error("convert msg to *tg.Message failed")
|
logger.Error("convert msg to *tg.Message failed", zap.Int64("channel", channel.ID))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
case *tg.MessageMediaDocument:
|
case *tg.MessageMediaDocument:
|
||||||
if docClass, ok := mediaClass.(*tg.MessageMediaDocument).GetDocument(); ok {
|
if docClass, ok := mediaClass.(*tg.MessageMediaDocument).GetDocument(); ok {
|
||||||
logger.Warn("document",
|
logger.Warn("document",
|
||||||
|
zap.Int64("channel", channel.ID),
|
||||||
zap.Int("msg_id", msg.ID),
|
zap.Int("msg_id", msg.ID),
|
||||||
zap.String("file_name", docClass.String()),
|
zap.String("file_name", docClass.String()),
|
||||||
)
|
)
|
||||||
@@ -76,6 +77,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
if doc.GetSize() > int64(t.Config.GetMaxSize()) {
|
if doc.GetSize() > int64(t.Config.GetMaxSize()) {
|
||||||
logger.Warn(
|
logger.Warn(
|
||||||
"document size too large",
|
"document size too large",
|
||||||
|
zap.Int64("channel", channel.ID),
|
||||||
zap.Int64("size", doc.GetSize()),
|
zap.Int64("size", doc.GetSize()),
|
||||||
zap.String("SizeHuman", humanize.Bytes(uint64(doc.GetSize()))),
|
zap.String("SizeHuman", humanize.Bytes(uint64(doc.GetSize()))),
|
||||||
)
|
)
|
||||||
@@ -84,7 +86,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
|
|
||||||
data, err := t.saveDocument(ctx, cfg, doc)
|
data, err := t.saveDocument(ctx, cfg, doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("save document failed", zap.Error(err))
|
logger.Error("save document failed", zap.Error(err), zap.Int64("channel", channel.ID))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
channelMessage.WithDocument(doc.GetID(), data)
|
channelMessage.WithDocument(doc.GetID(), data)
|
||||||
@@ -93,13 +95,17 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
if page, ok := mediaClass.(*tg.MessageMediaWebPage).GetWebpage().(*tg.WebPage); ok {
|
if page, ok := mediaClass.(*tg.MessageMediaWebPage).GetWebpage().(*tg.WebPage); ok {
|
||||||
channelMessage.WithWebPage(page.GetID(), page.Title, page.URL)
|
channelMessage.WithWebPage(page.GetID(), page.Title, page.URL)
|
||||||
} else {
|
} else {
|
||||||
logger.Warn("web_page", zap.String("url", mediaClass.(*tg.MessageMediaWebPage).GetWebpage().String()))
|
logger.Warn("web_page",
|
||||||
|
zap.Int64("channel", channel.ID),
|
||||||
|
zap.Int64("msg_id", page.GetID()),
|
||||||
|
zap.String("url", mediaClass.(*tg.MessageMediaWebPage).GetWebpage().String()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
case *tg.MessageMediaPhoto:
|
case *tg.MessageMediaPhoto:
|
||||||
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {
|
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {
|
||||||
photo := photoClass.(*tg.Photo)
|
photo := photoClass.(*tg.Photo)
|
||||||
if err := t.savePhoto(ctx, cfg, photo); err != nil {
|
if err := t.savePhoto(ctx, cfg, photo); err != nil {
|
||||||
logger.Error("save photo failed", zap.Error(err))
|
logger.Error("save photo failed", zap.Error(err), zap.Int64("channel", channel.ID))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
channelMessage.WithPhoto(photo.GetID(), "jpg")
|
channelMessage.WithPhoto(photo.GetID(), "jpg")
|
||||||
@@ -108,13 +114,13 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
|||||||
|
|
||||||
logger.Info("save message", zap.Int("id", channelMessage.ID))
|
logger.Info("save message", zap.Int("id", channelMessage.ID))
|
||||||
if err := cfg.SaveMessage(ctx, channelMessage); err != nil {
|
if err := cfg.SaveMessage(ctx, channelMessage); err != nil {
|
||||||
logger.Error("save message failed", zap.Error(err))
|
logger.Error("save message failed", zap.Error(err), zap.Int64("channel", channel.ID))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("update config", zap.Int("offset", cfg.Offset))
|
logger.Info("update config", zap.Int("offset", cfg.Offset), zap.Int64("channel", channel.ID))
|
||||||
if err := cfg.Update(ctx, item.GetID()); err != nil {
|
if err := cfg.Update(ctx, item.GetID()); err != nil {
|
||||||
logger.Error("update config failed", zap.Error(err))
|
logger.Error("update config failed", zap.Error(err), zap.Int64("channel", channel.ID))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 237 KiB |
|
Before Width: | Height: | Size: 188 KiB |
|
Before Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 178 KiB |
|
Before Width: | Height: | Size: 433 KiB |
|
Before Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 26 KiB |