приватные каналы
This commit is contained in:
@@ -13,6 +13,7 @@ type Channel struct {
|
||||
Title string
|
||||
AccessHash int64
|
||||
Pts int
|
||||
InviteLink string
|
||||
}
|
||||
|
||||
const channelIDOffset int64 = 1000000000000
|
||||
@@ -47,13 +48,14 @@ func NormalizeChatID(id int64) int64 {
|
||||
|
||||
func (c Channel) String() string {
|
||||
return fmt.Sprintf(
|
||||
"Channel{id=%s telegram_id=%d username=%q title=%q access_hash=%d pts=%d}",
|
||||
"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 != "",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,16 @@ type Post struct {
|
||||
}
|
||||
|
||||
func NewPost(channel Channel, messageID int, text string, views int) Post {
|
||||
link := ""
|
||||
if channel.Username != "" {
|
||||
link = fmt.Sprintf("https://t.me/%s/%d", channel.Username, messageID)
|
||||
}
|
||||
return Post{
|
||||
ID: uuid.New(),
|
||||
ChannelID: channel.ID,
|
||||
MessageID: messageID,
|
||||
Text: text,
|
||||
Link: fmt.Sprintf("https://t.me/%s/%d", channel.Username, messageID),
|
||||
Link: link,
|
||||
Views: views,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user