diff --git a/.gitignore b/.gitignore index 8ecb156..34e1251 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ go.work log.json log-*.json session.json -tdl-export.json \ No newline at end of file +tdl-export.json +./exporter \ No newline at end of file diff --git a/internal/client_channel.go b/internal/client_channel.go index cc82128..d5902cb 100644 --- a/internal/client_channel.go +++ b/internal/client_channel.go @@ -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 } diff --git a/photos/5080289404966253464.jpg b/photos/5080289404966253464.jpg deleted file mode 100644 index de916be..0000000 Binary files a/photos/5080289404966253464.jpg and /dev/null differ diff --git a/photos/6231198030200160942.jpg b/photos/6231198030200160942.jpg deleted file mode 100644 index 5459891..0000000 Binary files a/photos/6231198030200160942.jpg and /dev/null differ diff --git a/photos/6231217464927174265.jpg b/photos/6231217464927174265.jpg deleted file mode 100644 index 3243dbf..0000000 Binary files a/photos/6231217464927174265.jpg and /dev/null differ diff --git a/photos/6233085737046228669.jpg b/photos/6233085737046228669.jpg deleted file mode 100644 index 2534ed6..0000000 Binary files a/photos/6233085737046228669.jpg and /dev/null differ diff --git a/photos/6233145857998438088.jpg b/photos/6233145857998438088.jpg deleted file mode 100644 index 00d4582..0000000 Binary files a/photos/6233145857998438088.jpg and /dev/null differ diff --git a/photos/6233262887267318976.jpg b/photos/6233262887267318976.jpg deleted file mode 100644 index e132001..0000000 Binary files a/photos/6233262887267318976.jpg and /dev/null differ diff --git a/photos/6233262887267318982.jpg b/photos/6233262887267318982.jpg deleted file mode 100644 index 7bfb1f7..0000000 Binary files a/photos/6233262887267318982.jpg and /dev/null differ diff --git a/photos/6233262887267318983.jpg b/photos/6233262887267318983.jpg deleted file mode 100644 index d815c20..0000000 Binary files a/photos/6233262887267318983.jpg and /dev/null differ diff --git a/photos/6233264463520317073.jpg b/photos/6233264463520317073.jpg deleted file mode 100644 index b684c52..0000000 Binary files a/photos/6233264463520317073.jpg and /dev/null differ diff --git a/photos/6233486289991220934.jpg b/photos/6233486289991220934.jpg deleted file mode 100644 index c3065ad..0000000 Binary files a/photos/6233486289991220934.jpg and /dev/null differ