ручное парсер

This commit is contained in:
Artem Tsyrulnikov
2026-02-04 13:38:03 +03:00
parent 09145e510a
commit 6fc6a60bce
10 changed files with 145 additions and 110 deletions

View File

@@ -31,7 +31,7 @@ func (t *Telegram) GetChannelHistory(ctx context.Context, channel domain.Channel
return nil, nil
}
placements := make([]domain.Post, 0, len(messages.Messages))
posts := make([]domain.Post, 0, len(messages.Messages))
for _, raw := range messages.Messages {
m, ok := raw.(*tg.Message)
@@ -42,8 +42,8 @@ func (t *Telegram) GetChannelHistory(ctx context.Context, channel domain.Channel
text := messageToHTML(m.Message, m.Entities)
publishedAt := time.Unix(int64(m.Date), 0).UTC()
p := domain.NewPost(channel, m.ID, text, m.Views, publishedAt)
placements = append(placements, p)
posts = append(posts, p)
}
return placements, nil
return posts, nil
}

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/TelegramExchange/tgex-backend/tg_parser/internal/domain"
"github.com/google/uuid"
"github.com/gotd/td/tg"
)
@@ -49,7 +48,6 @@ func (t *Telegram) ParseChannelMeta(ctx context.Context, username string) (domai
}
return domain.Channel{
ID: uuid.New(),
TelegramID: domain.ChatIDFromChannelID(ch.ID),
Username: username,
Title: ch.Title,

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/TelegramExchange/tgex-backend/tg_parser/internal/domain"
"github.com/google/uuid"
"github.com/gotd/td/telegram/deeplink"
"github.com/gotd/td/tg"
)
@@ -64,12 +63,12 @@ func (t *Telegram) ParseChannelMetaByInvite(ctx context.Context, inviteLink stri
}
return domain.Channel{
ID: uuid.New(),
TelegramID: domain.ChatIDFromChannelID(channel.ID),
Username: username,
Title: channel.Title,
AccessHash: channel.AccessHash,
Pts: pts,
InviteLink: inviteLink,
IsAccessible: true,
}, nil
}