From 0c3749a2ca0ce8166dc50239f76d4ced03dc0c3a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 12 Dec 2025 15:54:55 +0200 Subject: [PATCH] gotd: don't start getDifference for left channels --- pkg/gotd/telegram/updates/state.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/gotd/telegram/updates/state.go b/pkg/gotd/telegram/updates/state.go index 077ab035..2d8db469 100644 --- a/pkg/gotd/telegram/updates/state.go +++ b/pkg/gotd/telegram/updates/state.go @@ -329,6 +329,21 @@ func (s *internalState) handleChannel(ctx context.Context, channelID int64, date s.log.Error("Pts validation failed", zap.Error(err), zap.Any("update", cu.update)) return nil } + for _, ent := range cu.entities.Chats { + if ent.GetID() == channelID { + switch te := ent.(type) { + case *tg.Channel: + if te.Left { + s.log.Info("Not adding new channel state for left channel", zap.Int64("channel_id", channelID)) + return nil + } + case *tg.ChannelForbidden: + s.log.Info("Not adding new channel state for forbidden channel", zap.Int64("channel_id", channelID)) + return nil + } + break + } + } s.channelsLock.Lock() state, ok := s.channels[channelID] @@ -374,6 +389,7 @@ func (s *internalState) handleChannel(ctx context.Context, channelID int64, date } } + s.log.Info("Adding new channel state", zap.Int64("channel_id", channelID), zap.Int("local_pts", localPts), zap.Int("remote_pts", pts)) state = s.createAndRunChannelState(ctx, channelID, accessHash, localPts) }