c0re100/go-tdlib — dự án mã nguồn mở — đang có 11 sao GitHub. Golang Telegram TdLib JSON bindings
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Telegram Tdlib is a complete library for creating telegram clients, it laso has a simple tdjson ready-to-use library to ease
the integration with different programming languages and platforms.
go-tdlib is a complete tdlib-tdjson binding package to help you create your own Telegram clients.
NOTE: basic tdjson-golang binding is inspired from this package: go-tdjson
All the classes and functions declared in Tdlib TypeLanguage schema
file have been exported using the autogenerate tool tl-parser.
So you can use every single type and method in Tdlib.
Key features:
Autogenerated golang structs and methods of tdlib .tl schema
Custom event receivers defined by user (e.g. get only text messages from a specific user)
Supports all tdjson functions: Send(), Execute(), Receive(), Destroy(), SetFilePath(), SetLogVerbosityLevel()
Supports all tdlib functions and types
Installation
First of all you need to clone the Tdlib repo and build it:
git clone [email protected]:tdlib/td.git
cd td
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -- -j5
make install
# -j5 refers to number of your cpu cores + 1 for multi-threaded build.
If hit any build errors, refer to Tdlib build instructions
I'm using static linking against tdlib so it won't require to build the whole tdlib source files.
Docker
You can use prebuilt tdlib with following Docker image:
Windows:
docker pull mihaildemidoff/tdlib-go
Example
Here is a simple example for authorization and fetching updates:
package main
import (
"fmt"
"github.com/Arman92/go-tdlib"
)
func main() {
tdlib.SetLogVerbosityLevel(1)
tdlib.SetFilePath("./errors.txt")
// Create new instance of client
client := tdlib.NewClient(tdlib.Config{
APIID: "187786",
APIHash: "e782045df67ba48e441ccb105da8fc85",
SystemLanguageCode: "en",
DeviceModel: "Server",
SystemVersion: "1.0.0",
ApplicationVersion: "1.0.0",
UseMessageDatabase: true,
UseFileDatabase: true,
UseChatInfoDatabase: true,
UseTestDataCenter: false,
DatabaseDirectory: "./tdlib-db",
FileDirectory: "./tdlib-files",
IgnoreFileNames: false,
})
for {
currentState, _ := client.Authorize()
if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPhoneNumberType {
fmt.Print("Enter phone: ")
var number string
fmt.Scanln(&number)
_, err := client.SendPhoneNumber(number)
if err != nil {
fmt.Printf("Error sending phone number: %v", err)
}
} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitCodeType {
fmt.Print("Enter code: ")
var code string
fmt.Scanln(&code)
_, err := client.SendAuthCode(code)
if err != nil {
fmt.Printf("Error sending auth code : %v", err)
}
} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPasswordType {
fmt.Print("Enter Password: ")
var password string
fmt.Scanln(&password)
_, err := client.SendAuthPassword(password)
if err != nil {
fmt.Printf("Error sending auth password: %v", err)
}
} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateReadyType {
fmt.Println("Authorization Ready! Let's rock")
break
}
}
// Main loop
for update := range client.RawUpdates {
// Show all updates
fmt.Println(update.Data)
fmt.Print("\n\n")
}
}
Có — c0re100/go-tdlib phát hành theo license GPL-3.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/c0re100/go-tdlib.
c0re100/go-tdlib là gì?
c0re100/go-tdlib (c0re100/go-tdlib) là dự án Go trên GitHub. Theo mô tả gốc: Golang Telegram TdLib JSON bindings
Đọc thêm về c0re100/go-tdlib ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/c0re100/go-tdlib là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
go-tdlib có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về go-tdlib.