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 }