приватные каналы
This commit is contained in:
33
tg_parser/internal/adapter/telegram/pts.go
Normal file
33
tg_parser/internal/adapter/telegram/pts.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/TelegramExchange/tgex-backend/tg_parser/internal/domain"
|
||||
"github.com/gotd/td/tg"
|
||||
)
|
||||
|
||||
func (t *Telegram) GetChannelPTS(ctx context.Context, channel domain.Channel) (int, error) {
|
||||
req := []tg.InputDialogPeerClass{
|
||||
&tg.InputDialogPeer{
|
||||
Peer: &tg.InputPeerChannel{
|
||||
ChannelID: channel.ChannelID(),
|
||||
AccessHash: channel.AccessHash,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
dialogs, err := t.API().MessagesGetPeerDialogs(ctx, req)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("peer dialogs: %w", err)
|
||||
}
|
||||
|
||||
if len(dialogs.Dialogs) > 0 {
|
||||
if d, ok := dialogs.Dialogs[0].(*tg.Dialog); ok {
|
||||
return d.Pts, nil
|
||||
}
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
Reference in New Issue
Block a user