Initial commit
Build & Push / build (push) Canceled after 0s

This commit is contained in:
2026-08-05 19:31:35 +03:00
commit a33fa24e99
272 changed files with 40566 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
package domain
import (
"fmt"
"github.com/google/uuid"
)
type Channel struct {
ID uuid.UUID
TelegramID int64
Username string
Title string
AccessHash int64
Pts int
InviteLink string
IsAccessible bool
}
const channelIDOffset int64 = 1000000000000
// ChannelID returns the positive channel identifier expected by Telegram API.
func (c Channel) ChannelID() int64 {
return ChannelIDFromChatID(c.TelegramID)
}
// ChannelIDFromChatID converts stored chat IDs (Bot API style) to channel IDs used by TDLib.
func ChannelIDFromChatID(chatID int64) int64 {
if chatID >= 0 {
return chatID
}
return -chatID - channelIDOffset
}
// ChatIDFromChannelID converts Telegram channel IDs to Bot API style chat IDs (-100...).
func ChatIDFromChannelID(channelID int64) int64 {
return -channelIDOffset - channelID
}
// NormalizeChatID ensures that TelegramID is stored in chat-id form (negative).
func NormalizeChatID(id int64) int64 {
if id < 0 {
return id
}
return ChatIDFromChannelID(id)
}
func (c Channel) String() string {
return fmt.Sprintf(
"Channel{id=%s telegram_id=%d username=%q title=%q access_hash=%d pts=%d invite_link=%t}",
c.ID,
c.TelegramID,
c.Username,
c.Title,
c.AccessHash,
c.Pts,
c.InviteLink != "",
)
}
type ChannelDiff struct {
NewPts int
NewPosts []Post
DeletedPosts []Post
UpdatedChannel *Channel
}
+36
View File
@@ -0,0 +1,36 @@
package domain
import (
"fmt"
"time"
"github.com/google/uuid"
)
type Post struct {
ID uuid.UUID
ChannelID uuid.UUID
MessageID int
Text string
Link string
Views int
PublishedAt time.Time
}
func NewPost(channel Channel, messageID int, text string, views int, publishedAt time.Time) Post {
link := ""
if channel.Username != "" {
link = fmt.Sprintf("https://t.me/%s/%d", channel.Username, messageID)
} else if channel.TelegramID != 0 {
link = fmt.Sprintf("https://t.me/c/%d/%d", ChannelIDFromChatID(channel.TelegramID), messageID)
}
return Post{
ID: uuid.New(),
ChannelID: channel.ID,
MessageID: messageID,
Text: text,
Link: link,
Views: views,
PublishedAt: publishedAt,
}
}
@@ -0,0 +1,14 @@
package domain
import (
"time"
"github.com/google/uuid"
)
type ViewsSnapshot struct {
ViewsCount int
FetchedAt time.Time
PostID uuid.UUID
}