package telegramimport ()// DeviceConfig is config which send when Telegram connection session created.typeDeviceConfig = manager.DeviceConfig// Telegram Desktop application version sent in initConnection.//// Keep in sync with the bundled tdesktop reference (Telegram/SourceFiles/core/version.h).consttdesktopAppVersion = "6.9.1"// TimezoneParams builds the initConnection params value with the tz_offset// field, matching what the official clients (e.g. Telegram Desktop) send.//// The offset is the timezone offset of loc in seconds, rounded to the nearest// 15 minutes (900 seconds) and clamped to the [-12h, +14h] range, exactly like// Telegram Desktop's prepareInitParams.func ( *time.Location) tg.JSONValueClass { , := time.Now().In().Zone()for < -12*3600 { += 24 * 3600 }for > 14*3600 { -= 24 * 3600 } := 1if < 0 { = -1 = - } := (( + 450) / 900) * 900 * return &tg.JSONObject{Value: []tg.JSONObjectValue{ {Key: "tz_offset", Value: &tg.JSONNumber{Value: float64()}}, }, }}// TDesktopResolver returns a DC resolver that connects the same way as Telegram// Desktop: every direct connection is wrapped in Obfuscated2 and uses the// abridged transport codec.//// Use it together with DeviceTDesktopWindows to be indistinguishable from// Telegram Desktop both on the transport layer and in initConnection://// client := telegram.NewClient(appID, appHash, telegram.Options{// Device: telegram.DeviceTDesktopWindows(),// Resolver: telegram.TDesktopResolver(),// })func () dcs.Resolver {returndcs.Plain(dcs.PlainOptions{Protocol: transport.Abridged,Obfuscated: true, })}// DeviceTDesktopWindows returns a DeviceConfig that emulates a Telegram Desktop// (Windows build) installation on initConnection, making the connection// parameters indistinguishable from Telegram Desktop from the server's// perspective.//// Combine it with TDesktopResolver to also match Telegram Desktop on the// transport layer.func () DeviceConfig {returnDeviceConfig{DeviceModel: "Desktop",SystemVersion: "Windows 10",AppVersion: tdesktopAppVersion + " x64",SystemLangCode: "en-US",LangPack: "tdesktop",LangCode: "en",Params: TimezoneParams(time.Local), }}
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.