парсер

This commit is contained in:
Artem Tsyrulnikov
2026-01-06 21:04:42 +03:00
parent b77e4fd0b6
commit 2c0ae2dfc3
45 changed files with 2202 additions and 51 deletions

View File

@@ -0,0 +1,38 @@
package usecase
import (
"context"
"github.com/TelegramExchange/tgex-parser/internal/domain"
)
type Telegram interface {
ParseChannelMeta(ctx context.Context, username string) (domain.Channel, error)
GetChannelHistory(ctx context.Context, channel domain.Channel, limit int) ([]domain.Post, error)
GetChannelDiff(ctx context.Context, channel domain.Channel, limit int) (domain.ChannelDiff, error)
UpdatePostsViews(ctx context.Context, channel domain.Channel, posts []domain.Post) error
}
type Database interface {
CreatePost(ctx context.Context, post domain.Post) error
CreateViewsSnapshot(ctx context.Context, snapshot domain.ViewsSnapshot) error
GetChannels(ctx context.Context) []domain.Channel
UpdateChannel(ctx context.Context, channel domain.Channel) error
GetChannelsWithTrackedPosts(ctx context.Context) ([]domain.Channel, error)
GetTrackedPosts(ctx context.Context, channel domain.Channel) ([]domain.Post, error)
DeletePost(ctx context.Context, p domain.Post) error
}
type UseCase struct {
telegram Telegram
database Database
}
func New(telegram Telegram, database Database) *UseCase {
return &UseCase{
telegram: telegram,
database: database,
}
}