fix: issues
3
.gitignore
vendored
@@ -25,4 +25,5 @@ go.work
|
||||
log.json
|
||||
log-*.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")
|
||||
}
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
||||
|
||||
msg, ok := item.(*tg.Message)
|
||||
if !ok {
|
||||
logger.Error("convert msg to *tg.Message failed")
|
||||
logger.Error("convert msg to *tg.Message failed", zap.Int64("channel", channel.ID))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChann
|
||||
case *tg.MessageMediaDocument:
|
||||
if docClass, ok := mediaClass.(*tg.MessageMediaDocument).GetDocument(); ok {
|
||||
logger.Warn("document",
|
||||
zap.Int64("channel", channel.ID),
|
||||
zap.Int("msg_id", msg.ID),
|
||||
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()) {
|
||||
logger.Warn(
|
||||
"document size too large",
|
||||
zap.Int64("channel", channel.ID),
|
||||
zap.Int64("size", 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)
|
||||
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
|
||||
}
|
||||
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 {
|
||||
channelMessage.WithWebPage(page.GetID(), page.Title, page.URL)
|
||||
} 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:
|
||||
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {
|
||||
photo := photoClass.(*tg.Photo)
|
||||
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
|
||||
}
|
||||
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))
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
logger.Error("update config failed", zap.Error(err))
|
||||
logger.Error("update config failed", zap.Error(err), zap.Int64("channel", channel.ID))
|
||||
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 |