{"id":13610094,"url":"https://github.com/gotd/td","last_synced_at":"2026-10-19T08:43:37.537Z","repository":{"id":36963006,"uuid":"312623308","full_name":"gotd/td","owner":"gotd","description":"Telegram client, in Go. (MTProto API)","archived":false,"fork":false,"pushed_at":"2026-10-09T14:39:22.000Z","size":60675,"stargazers_count":2360,"open_issues_count":16,"forks_count":209,"subscribers_count":29,"default_branch":"main","last_synced_at":"2026-10-17T10:15:20.592Z","etag":null,"topics":["bot-api","go","golang","mtproto","tdlib","telegram","telegram-api","telegram-bot"],"latest_commit_sha":null,"homepage":"https://gotd.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":".github/SUPPORT.md","governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"polar":"gotd"}},"created_at":"2020-11-13T16:10:09.000Z","updated_at":"2026-10-15T17:50:13.000Z","dependencies_parsed_at":"2026-01-07T11:07:35.924Z","dependency_job_id":null,"html_url":"https://github.com/gotd/td","commit_stats":{"total_commits":2702,"total_committers":28,"mean_commits":96.5,"dds":0.6780162842339008,"last_synced_commit":"1bf78b6f6d86de0b735de9a5dd365d82de91a0d9"},"previous_names":["ernado/td"],"tags_count":253,"template":false,"template_full_name":null,"purl":"pkg:github/gotd/td","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotd%2Ftd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotd%2Ftd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotd%2Ftd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotd%2Ftd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotd","download_url":"https://codeload.github.com/gotd/td/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotd%2Ftd/sbom","scorecard":{"id":97823,"data":{"date":"2025-08-11","repo":{"name":"github.com/gotd/td","commit":"9d1e645fc06ef939337396c0360e52fd01bdff29"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":6.2,"checks":[{"name":"Maintained","score":10,"reason":"30 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/1 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/bench.yml:1","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/commitlint.yml:1","Warn: no topLevel permission defined: .github/workflows/coverage.yml:1","Warn: no topLevel permission defined: .github/workflows/e2e.yml:1","Warn: no topLevel permission defined: .github/workflows/lint.yml:1","Warn: no topLevel permission defined: .github/workflows/nightly.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/update-schema.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: .github/SECURITY.md:1","Info: Found linked content: .github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/SECURITY.md:1","Info: Found text in security policy: .github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: GoBuiltInFuzzer integration found: crypto/fuzz_test.go:13","Info: GoBuiltInFuzzer integration found: exchange/fuzz_test.go:17","Info: GoBuiltInFuzzer integration found: fileid/decode_fuzz_test.go:9","Info: GoBuiltInFuzzer integration found: fileid/file_id_fuzz_test.go:15","Info: GoBuiltInFuzzer integration found: telegram/deeplink/deeplink_fuzz_test.go:17"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/bench.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/bench.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/bench.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/bench.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/bench.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/commitlint.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/commitlint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/commitlint.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/commitlint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/coverage.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/coverage.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/e2e.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/e2e.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/e2e.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/e2e.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/e2e.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/e2e.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nightly.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/nightly.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nightly.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/nightly.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-schema.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/update-schema.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-schema.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/update-schema.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-schema.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/update-schema.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-schema.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/update-schema.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-schema.yml:64: update your workflow using https://app.stepsecurity.io/secureworkflow/gotd/td/update-schema.yml/main?enable=pin","Warn: containerImage not pinned by hash: cmd/connclose/Dockerfile:1: pin your Docker image by updating ubuntu:latest to ubuntu:latest@sha256:7c06e91f61fa88c08cc74f7e1b7c69ae24910d745357e0dfe1d2c0322aaf20f9","Warn: goCommand not pinned by hash: .github/workflows/e2e.yml:40","Info:   0 out of  26 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   7 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T09:27:28.780Z","repository_id":36963006,"created_at":"2025-08-15T09:27:28.780Z","updated_at":"2025-08-15T09:27:28.780Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38333982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-17T02:00:06.547Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot-api","go","golang","mtproto","tdlib","telegram","telegram-api","telegram-bot"],"created_at":"2024-08-01T19:01:41.138Z","updated_at":"2026-10-19T08:43:35.714Z","avatar_url":"https://github.com/gotd.png","language":"Go","funding_links":["https://polar.sh/gotd"],"categories":["Go","Bots","Media API"],"sub_categories":["Bot Libs"],"readme":"# td [![Go Reference](https://img.shields.io/badge/go-pkg-00ADD8)](https://pkg.go.dev/github.com/gotd/td#section-documentation) [![codecov](https://img.shields.io/codecov/c/github/gotd/td?label=cover)](https://codecov.io/gh/gotd/td) [![beta](https://img.shields.io/badge/-beta-yellow)](https://go-faster.org/docs/projects/status#beta)\n\nTelegram MTProto API client in Go for users and bots.\n\n[![Telegram: English chat](https://api.go-faster.org/badge/telegram/gotd_en?title=EN\u0026v=1)](https://t.me/gotd_en) [![Telegram: Russian chat](https://api.go-faster.org/badge/telegram/gotd_ru?title=RU\u0026v=1)](https://t.me/gotd_ru) [![Telegram: Chinese chat](https://api.go-faster.org/badge/telegram/gotd_zhcn?title=CN\u0026v=1)](https://t.me/gotd_zhcn) [![Telegram: Online count](https://api.go-faster.org/badge/telegram/online?groups=gotd_ru\u0026groups=gotd_en\u0026groups=gotd_zhcn)](https://t.me/gotd_en)\n\n* [Examples](examples)\n* [Security policy](.github/SECURITY.md)\n* [User support and dev chat](.github/SUPPORT.md)\n* [Roadmap](ROADMAP.md)\n* [Contributing](CONTRIBUTING.md)\n* [Architecture](ARCHITECTURE.md)\n* [Generated Go Documentation](https://ref.gotd.dev/pkg/github.com/gotd/td/tg.html)\n\nBefore using this library, read [How To Not Get Banned](.github/SUPPORT.md#how-to-not-get-banned) guide.\n\nDue to limitations of `pkg.go.dev`, documentation for `tg` package is not shown, but there is [hosted version](https://ref.gotd.dev/pkg/github.com/gotd/td/tg.html).\n\n## Higher level libraries\n\nThe `gotd` itself is a pretty low-level library, and you may want to use higher level libraries instead:\n- [GoTGProto][gotgproto] is a helper package for gotd library, It aims to make td's raw functions easy-to-use with the help of features like using session strings, custom helper functions, storing peers and extracting chat or user ids through it etc.\n\n[gotgproto]: https://github.com/celestix/gotgproto\n\n## Usage\n\n```console\ngo get github.com/gotd/td\n```\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/gotd/td/telegram\"\n)\n\nfunc main() {\n\t// https://core.telegram.org/api/obtaining_api_id\n\tclient := telegram.NewClient(appID, appHash, telegram.Options{})\n\tif err := client.Run(context.Background(), func(ctx context.Context) error {\n\t\t// It is only valid to use client while this function is not returned\n\t\t// and ctx is not cancelled.\n\t\tapi := client.API()\n\n\t\t// Now you can invoke MTProto RPC requests by calling the API.\n\t\t// ...\n\n\t\t// Return to close client connection and free up resources.\n\t\treturn nil\n\t}); err != nil {\n\t\tpanic(err)\n\t}\n\t// Client is closed.\n}\n```\n\nSee [examples](examples) for more info.\n\n## Features\n\n* Full MTProto 2.0 implementation in Golang, directly access any MTProto method with [telegram.Client.API()](https://pkg.go.dev/github.com/gotd/td@v0.60.0/telegram#Client.API)\n* Highly optimized, low memory (150kb per idle client) and CPU overhead, can handle thousands concurrent clients\n* Code for Telegram types generated by `./cmd/gotdgen` (based on [gotd/tl](https://github.com/gotd/tl) parser) with embedded [official documentation](https://core.telegram.org/schema)\n* Pluggable session storage\n* Automatic re-connects with keepalive\n* Vendored Telegram public keys that are kept up-to-date\n* Rigorously tested\n  * End-to-end with real Telegram server in CI\n  * End-to-end with gotd Telegram server (in pure Go)\n  * Lots of unit testing\n  * Fuzzing\n  * 24/7 canary bot in production that tests reconnects, update handling, memory leaks and performance\n* No runtime reflection overhead\n* [Conforms](https://github.com/gotd/td/issues/155) to [Security guidelines](https://core.telegram.org/mtproto/security_guidelines) for Telegram client software developers\n  * Secure PRNG used for crypto\n  * Replay attack protection\n* 2FA support\n* MTProxy support\n* Various helpers that lighten the complexity of the Telegram API\n  * [uploads](https://pkg.go.dev/github.com/gotd/td/telegram/uploader) for big and small files with multiple streams for single file and progress reporting\n  * [downloads](https://pkg.go.dev/github.com/gotd/td/telegram/downloader) with CDN support, also multiple streams\n  * [messages](https://pkg.go.dev/github.com/gotd/td/telegram/message) with various convenience builders and text styling support\n  * [query](https://pkg.go.dev/github.com/gotd/td/telegram/query) with pagination helpers\n  * [middleware](https://pkg.go.dev/github.com/gotd/td/telegram#Middleware) for [rate limiting](https://pkg.go.dev/github.com/gotd/contrib/middleware/ratelimit) and [FLOOD_WAIT handling](https://pkg.go.dev/github.com/gotd/contrib/middleware/floodwait)\n* Connection pooling\n* Automatic datacenter migration and redirects handling\n* Graceful [request cancellation](https://core.telegram.org/mtproto/service_messages#cancellation-of-an-rpc-query) via context\n* WebSocket transport support (works in WASM)\n\n## Status\n\nThe goal of this project is to implement a stable, performant and safe client for Telegram in pure Go while\nhaving a simple and convenient API and a feature parity with TDLib.\n\nThis project is fully non-commercial and not affiliated with any commercial organization\n(including Telegram LLC).\n\n## Examples\n\nSee [examples](examples) directory.\n\nAlso take a look at\n\n* [go-faster/bot](https://github.com/go-faster/bot) as example of sophisticated telegram bot integration with GitHub\n* [gotd/cli](https://github.com/gotd/cli), command line interface for subset of telegram methods.\n\n### Auth\n\n#### User\n\nYou can use `td/telegram/auth.Flow` to simplify user authentications.\n\n```go\ncodePrompt := func(ctx context.Context, sentCode *tg.AuthSentCode) (string, error) {\n    // NB: Use \"golang.org/x/crypto/ssh/terminal\" to prompt password.\n    fmt.Print(\"Enter code: \")\n    code, err := bufio.NewReader(os.Stdin).ReadString('\\n')\n    if err != nil {\n        return \"\", err\n    }\n    return strings.TrimSpace(code), nil\n}\n// This will setup and perform authentication flow.\n// If account does not require 2FA password, use telegram.CodeOnlyAuth\n// instead of telegram.ConstantAuth.\nif err := auth.NewFlow(\n    auth.Constant(phone, password, auth.CodeAuthenticatorFunc(codePrompt)),\n    auth.SendCodeOptions{},\n).Run(ctx, client.Auth()); err != nil {\n    panic(err)\n}\n```\n\n#### Bot\n\nUse bot token from [@BotFather](https://telegram.me/BotFather).\n\n```go\nif err := client.Auth().Bot(ctx, \"token:12345\"); err != nil {\n    panic(err)\n}\n```\n\n### Calling MTProto directly\n\nYou can use the generated `tg.Client` that allows calling any MTProto method\ndirectly.\n\n```go\n// Grab these from https://my.telegram.org/apps.\n// Never share it or hardcode!\nclient := telegram.NewClient(appID, appHash, telegram.Options{})\nclient.Run(ctx, func(ctx context.Context) error {\n  // Grab token from @BotFather.\n  if _, err := client.Auth().Bot(ctx, \"token:12345\"); err != nil {\n    return err\n  }\n  state, err := client.API().UpdatesGetState(ctx)\n  if err != nil {\n    return err\n  }\n  // Got state: \u0026{Pts:197 Qts:0 Date:1606855030 Seq:1 UnreadCount:106}\n  // This will close client and cleanup resources.\n  return nil\n})\n```\n\n### Generated code\n\nThe code output of `gotdgen` contains references to TL types, examples, URL to\nofficial documentation and [extracted](https://github.com/gotd/getdoc) comments from it.\n\nFor example, the [auth.Authorization](https://core.telegram.org/type/auth.Authorization) type in `tg/tl_auth_authorization_gen.go`:\n\n```go\n// AuthAuthorizationClass represents auth.Authorization generic type.\n//\n// See https://core.telegram.org/type/auth.Authorization for reference.\n//\n// Example:\n//  g, err := DecodeAuthAuthorization(buf)\n//  if err != nil {\n//      panic(err)\n//  }\n//  switch v := g.(type) {\n//  case *AuthAuthorization: // auth.authorization#cd050916\n//  case *AuthAuthorizationSignUpRequired: // auth.authorizationSignUpRequired#44747e9a\n//  default: panic(v)\n//  }\ntype AuthAuthorizationClass interface {\n\tbin.Encoder\n\tbin.Decoder\n\tconstruct() AuthAuthorizationClass\n}\n```\n\nAlso, the corresponding [auth.signIn](https://core.telegram.org/method/auth.signIn) method:\n\n```go\n// AuthSignIn invokes method auth.signIn#bcd51581 returning error if any.\n// Signs in a user with a validated phone number.\n//\n// See https://core.telegram.org/method/auth.signIn for reference.\nfunc (c *Client) AuthSignIn(ctx context.Context, request *AuthSignInRequest) (AuthAuthorizationClass, error) {}\n```\n\nThe generated constructors contain detailed official documentation, including links:\n\n```go\n// FoldersDeleteFolderRequest represents TL type `folders.deleteFolder#1c295881`.\n// Delete a peer folder¹\n//\n// Links:\n//  1) https://core.telegram.org/api/folders#peer-folders\n//\n// See https://core.telegram.org/method/folders.deleteFolder for reference.\ntype FoldersDeleteFolderRequest struct {\n    // Peer folder ID, for more info click here¹\n    //\n    // Links:\n    //  1) https://core.telegram.org/api/folders#peer-folders\n    FolderID int\n}\n```\n\n## Contributions\n\nHuge thanks to all contributors. Dealing with a project of this scale alone is impossible.\n\nSpecial thanks:\n\n* [tdakkota](https://github.com/tdakkota)\n  * Two-factor authentication (SRP)\n  * Proxy support\n  * Update dispatcher\n  * Complete transport support (abridged, padded intermediate and full)\n  * Telegram server for end-to-end testing\n  * Multiple major refactorings, including critical cryptographical scope reduction\n  * Code generation improvements (vector support, multiple modes for pretty-print)\n  * And many other cool things and performance improvements\n* [shadowspore](https://github.com/shadowspore)\n  * Background pings\n  * Links in generated documentation\n  * Message acknowledgements\n  * Retries\n  * RPC Engine\n  * Gap (Updates) engine\n\n## Reference\n\nThe MTProto protocol description is [hosted](https://core.telegram.org/mtproto#general-description) by Telegram.\n\nMost important parts for client implementations:\n\n* [Security guidelines](https://core.telegram.org/mtproto/security_guidelines) for client software developers\n\nCurrent implementation [mostly conforms](https://github.com/gotd/td/issues/155) to security guidelines, but no\nformal security audit were performed.\n\n## Prior art\n\n* [Lonami/grammers](https://github.com/Lonami/grammers) (Great Telegram client in Rust, many test vectors were used as reference)\n* [sdidyk/mtproto](https://github.com/sdidyk/mtproto), [cjongseok/mtproto](https://github.com/cjongseok/mtproto), [xelaj/mtproto](https://github.com/xelaj/mtproto) (MTProto 1.0 in go)\n\n## Who is using gotd?\n\n- The [iyear/tdl](https://github.com/iyear/tdl), 📥 Telegram Downloader, but more than a downloader\n\n[\u003cimg src=\"https://user-images.githubusercontent.com/43930873/142855897-7091ced0-4fe8-4f8d-ad43-e9db2723bacc.png\" width=\"150\"\u003e](https://telq.org)\n\nDrop a comment [here](https://github.com/gotd/td/issues/568) to add your project.\n\n## License\n\nMIT License\n\nCreated by Aleksandr (ernado) Razumov\n\n2020\n\n## Links\n\n- [Examples](https://github.com/gotd/td/blob/-/examples/README.md)\n- [Security policy](https://github.com/gotd/td/blob/-/.github/SECURITY.md)\n- [User support and dev chat](https://github.com/gotd/td/blob/-/.github/SUPPORT.md)\n- [Roadmap](https://github.com/gotd/td/blob/-/ROADMAP.md)\n- [Contributing](https://github.com/gotd/td/blob/-/CONTRIBUTING.md)\n- [Architecture](https://github.com/gotd/td/blob/-/ARCHITECTURE.md)\n- [Generated Go Documentation](https://ref.gotd.dev/pkg/github.com/gotd/td/tg.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotd%2Ftd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotd%2Ftd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotd%2Ftd/lists"}