{"id":20463499,"url":"https://github.com/kaoriel/go-tdlib","last_synced_at":"2025-05-08T23:32:26.256Z","repository":{"id":57617545,"uuid":"386164972","full_name":"KaoriEl/go-tdlib","owner":"KaoriEl","description":"Library for working with golang telegram client + bot based on tdlib.  This library was taken from the user Arman92 and changed for the current version of tdlib.","archived":false,"fork":false,"pushed_at":"2023-05-29T09:40:05.000Z","size":756,"stargazers_count":32,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T02:24:55.692Z","etag":null,"topics":["awesome","go","golang","golang-library","php","tdlib","tdlib-go","telegram","telegram-bot","telegram-cli-bot","telegram-client","telegram-desktop"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KaoriEl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-15T04:40:44.000Z","updated_at":"2024-02-13T19:34:24.000Z","dependencies_parsed_at":"2024-06-19T01:35:53.998Z","dependency_job_id":"2042da03-ff3f-4e8d-9f31-8accc079157d","html_url":"https://github.com/KaoriEl/go-tdlib","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaoriEl%2Fgo-tdlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaoriEl%2Fgo-tdlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaoriEl%2Fgo-tdlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KaoriEl%2Fgo-tdlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KaoriEl","download_url":"https://codeload.github.com/KaoriEl/go-tdlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224784943,"owners_count":17369461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["awesome","go","golang","golang-library","php","tdlib","tdlib-go","telegram","telegram-bot","telegram-cli-bot","telegram-client","telegram-desktop"],"created_at":"2024-11-15T13:11:40.259Z","updated_at":"2024-11-15T13:11:41.144Z","avatar_url":"https://github.com/KaoriEl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-tdlib\nGolang Telegram TdLib JSON bindings\n\n## Install\n\nTo install, you need to run inside a docker container (it is given below)\n```\ngo get -u github.com/kaoriEl/go-tdlib\n```\n## Introduction\n\n*Library for working with golang based on tdlib.*\n\n*This library was taken from the user Arman92 and changed for the current version of tdlib.*\n\nTelegram Tdlib is a complete library for creating telegram clients, it also has a simple tdjson ready-to-use library to ease\nthe integration with different programming languages and platforms.\n\n**go-tdlib** is a complete tdlib-tdjson binding package to help you create your own Telegram clients.\n\n**NOTE:** basic tdjson-golang binding is inspired from this package: [go-tdjson](https://github.com/L11R/go-tdjson)\n\nAll the classes and functions declared in [Tdlib TypeLanguage schema](https://github.com/tdlib/td/blob/master/td/generate/scheme/td_api.tl)\nSo you can use every single type and method in Tdlib.\n\n## Key features:\n* Autogenerated golang structs and methods of tdlib .tl schema\n* Custom event receivers defined by user (e.g. get only text messages from a specific user)\n* Supports all tdjson functions: Send(), Execute(), Receive(), Destroy(), SetFilePath(), SetLogVerbosityLevel()\n* Supports all tdlib functions and types\n\n## Docker\nYou can use prebuilt tdlib with following Docker image: \n\n***DockerFile with supervisord:***\n``` shell\nFROM jancimertel/golang-1.16-tdlib AS build\n\nWORKDIR ./var/www\n\n# Updates the repository and installs git\nRUN apk update \u0026\u0026 apk upgrade \u0026\u0026 \\\n    apk add --no-cache git supervisor\n\nRUN apk update \u0026\u0026 apk add --no-cache supervisor\n\nCOPY ./%YourPath%/supervisord.conf /etc/supervisord.conf\n\n\nCOPY /%YourGoScript% .\nRUN go mod download\n\n# Runs the binary once the container starts\nCMD [\"/usr/bin/supervisord\", \"-n\"]\n```\n\n## Example\nHere is a simple example for authorization and fetching updates:\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/kaoriEl/go-tdlib\"\n)\n\nfunc main() {\n\ttdlib.SetLogVerbosityLevel(1)\n\ttdlib.SetFilePath(\"./errors.txt\")\n\n\t// Create new instance of client\n\tclient := tdlib.NewClient(tdlib.Config{\n\t\tAPIID:               \"187786\",\n\t\tAPIHash:             \"e782045df67ba48e441ccb105da8fc85\",\n\t\tSystemLanguageCode:  \"en\",\n\t\tDeviceModel:         \"Server\",\n\t\tSystemVersion:       \"1.0.0\",\n\t\tApplicationVersion:  \"1.0.0\",\n\t\tUseMessageDatabase:  true,\n\t\tUseFileDatabase:     true,\n\t\tUseChatInfoDatabase: true,\n\t\tUseTestDataCenter:   false,\n\t\tDatabaseDirectory:   \"./tdlib-db\",\n\t\tFileDirectory:       \"./tdlib-files\",\n\t\tIgnoreFileNames:     false,\n\t})\n\n\tfor {\n\t\tcurrentState, _ := client.Authorize()\n\t\tif currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPhoneNumberType {\n\t\t\tfmt.Print(\"Enter phone: \")\n\t\t\tvar number string\n\t\t\tfmt.Scanln(\u0026number)\n\t\t\t_, err := client.SendPhoneNumber(number)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Error sending phone number: %v\", err)\n\t\t\t}\n\t\t} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitCodeType {\n\t\t\tfmt.Print(\"Enter code: \")\n\t\t\tvar code string\n\t\t\tfmt.Scanln(\u0026code)\n\t\t\t_, err := client.SendAuthCode(code)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Error sending auth code : %v\", err)\n\t\t\t}\n\t\t} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPasswordType {\n\t\t\tfmt.Print(\"Enter Password: \")\n\t\t\tvar password string\n\t\t\tfmt.Scanln(\u0026password)\n\t\t\t_, err := client.SendAuthPassword(password)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Error sending auth password: %v\", err)\n\t\t\t}\n\t\t} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateReadyType {\n\t\t\tfmt.Println(\"Authorization Ready! Let's rock\")\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Main loop\n\tfor update := range client.RawUpdates {\n\t\t// Show all updates\n\t\tfmt.Println(update.Data)\n\t\tfmt.Print(\"\\n\\n\")\n\t}\n\n}\n\n```\n\nMore examples can be found on [examples folder](https://github.com/KaoriEl/go-tdlib/tree/master/examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaoriel%2Fgo-tdlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaoriel%2Fgo-tdlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaoriel%2Fgo-tdlib/lists"}