Documentation ¶
Overview ¶
Package tdesktop contains Telegram Desktop session decoder.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyInfoDecrypt is returned when key data decrypt fails. // It can happen if passed passcode is wrong. ErrKeyInfoDecrypt = errors.New("key data decrypt") // ErrNoAccounts reports that decoded tdata does not contain any accounts info. ErrNoAccounts = errors.New("tdesktop data does not contain accounts") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // IDx is an internal Telegram Desktop account ID. IDx uint32 // Authorization contains Telegram user and MTProto sessions. Authorization MTPAuthorization // Config contains Telegram config. Config MTPConfig }
Account is a Telegram user account representation in Telegram Desktop storage.
func Read ¶
Read reads accounts info from given Telegram Desktop tdata root. Shorthand for:
ReadFS(os.DirFS(root), passcode)
Example ¶
package main import ( "fmt" "os" "path/filepath" "github.com/voyager-hang/gotd-td/session/tdesktop" ) func main() { home, err := os.UserHomeDir() if err != nil { panic(err) } root := filepath.Join(home, "Downloads", "Telegram", "tdata") accounts, err := tdesktop.Read(root, nil) if err != nil { panic(err) } for _, account := range accounts { auth := account.Authorization cfg := account.Config fmt.Println(auth.UserID, auth.MainDC, cfg.Environment) } }
Output:
type MTPAuthorization ¶
type MTPAuthorization struct { // UserID is a Telegram user ID. UserID uint64 // MainDC is a main DC ID of this user. MainDC int // Key is a map of keys per DC ID. Keys map[int]crypto.Key // DC ID -> Key }
MTPAuthorization is a Telegram Desktop storage structure which stores MTProto session info.
See https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/SourceFiles/main/main_account.cpp#L359.
type MTPConfig ¶
type MTPConfig struct { Environment MTPConfigEnvironment DCOptions MTPDCOptions ChatSizeMax int32 // default: 200 MegagroupSizeMax int32 // default: 10000 ForwardedCountMax int32 // default: 100 OnlineUpdatePeriod int32 // default: 120000 OfflineBlurTimeout int32 // default: 5000 OfflineIdleTimeout int32 // default: 30000 OnlineFocusTimeout int32 // default: 1000 OnlineCloudTimeout int32 // default: 300000 NotifyCloudDelay int32 // default: 30000 NotifyDefaultDelay int32 // default: 1500 SavedGifsLimit int32 // default: 200 EditTimeLimit int32 // default: 172800 RevokeTimeLimit int32 // default: 172800 RevokePrivateTimeLimit int32 // default: 172800 RevokePrivateInbox bool // default: false StickersRecentLimit int32 // default: 30 StickersFavedLimit int32 // default: 5 PinnedDialogsCountMax int32 // default: 5 PinnedDialogsInFolderMax int32 // default: 100 InternalLinksDomain string // default: "https://t.me/" ChannelsReadMediaPeriod int32 // default: 86400 * 7 CallReceiveTimeoutMs int32 // default: 20000 CallRingTimeoutMs int32 // default: 90000 CallConnectTimeoutMs int32 // default: 30000 CallPacketTimeoutMs int32 // default: 10000 WebFileDCID int32 // default: 4 TxtDomainString string // default: "" PhoneCallsEnabled bool // default: true BlockedMode bool // default: false CaptionLengthMax int32 // default: 1024 }
MTPConfig is a Telegram Desktop storage structure which stores MTProto config info.
type MTPConfigEnvironment ¶
type MTPConfigEnvironment int32
MTPConfigEnvironment is enum of config environment.
func (MTPConfigEnvironment) String ¶
func (e MTPConfigEnvironment) String() string
String implements fmt.Stringer.
func (MTPConfigEnvironment) Test ¶
func (e MTPConfigEnvironment) Test() bool
Test denotes that environment is test.
type MTPDCOption ¶
MTPDCOption is a Telegram Desktop storage structure which stores DC info.
func (MTPDCOption) IPv6 ¶
func (m MTPDCOption) IPv6() bool
IPv6 denotes that the specified IP is an IPv6 address.
func (MTPDCOption) MediaOnly ¶
func (m MTPDCOption) MediaOnly() bool
MediaOnly denotes that this DC should only be used to download or upload files.
func (MTPDCOption) Static ¶
func (m MTPDCOption) Static() bool
Static denotes that this IP should be used when connecting through a proxy.
func (MTPDCOption) TCPOOnly ¶
func (m MTPDCOption) TCPOOnly() bool
TCPOOnly denotes that this DC only supports connection with transport obfuscation.
type MTPDCOptions ¶
type MTPDCOptions struct {
Options []MTPDCOption
}
MTPDCOptions is a Telegram Desktop storage structure which stores DCs info.
type WrongMagicError ¶
type WrongMagicError struct {
Magic [4]byte
}
WrongMagicError is returned when tdesktop data file has wrong magic header.