Telegram TDLib 客户端
在 Delphi/C++ Builder 中构建 Telegram 用户账户或机器人应用程序。封装官方 Telegram TDLib,公开身份验证、聊天、消息和更新事件。
在 Delphi/C++ Builder 中构建 Telegram 用户账户或机器人应用程序。封装官方 Telegram TDLib,公开身份验证、聊天、消息和更新事件。
官方 Telegram TDLib(tdjson)的 Delphi/C++ Builder 封装器。处理 client_id 生命周期、身份验证状态、消息发送/接收和长轮询更新流。
TsgcTDLib_Telegram
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
设置 ApiId / ApiHash,将组件指向 tdjson 库,绑定 OnTelegramUpdate 处理身份验证状态,并开始发送消息。
uses
sgcLibs;
var
Telegram: TsgcTDLib_Telegram;
begin
Telegram := TsgcTDLib_Telegram.Create(nil);
Telegram.TDLibParameters.ApiId := 123456;
Telegram.TDLibParameters.ApiHash := 'your-api-hash';
Telegram.LibraryPath := 'tdjson.dll';
Telegram.OnTelegramUpdate := procedure(Sender: TObject;
const aUpdate: string)
begin
Memo1.Lines.Add(aUpdate);
end;
Telegram.Active := True;
Telegram.SendMessage('@username', 'hello from Delphi');
end;
// uses: sgcLibs
TsgcTDLib_Telegram *Telegram = new TsgcTDLib_Telegram(this);
Telegram->TDLibParameters->ApiId = 123456;
Telegram->TDLibParameters->ApiHash = "your-api-hash";
Telegram->LibraryPath = "tdjson.dll";
Telegram->Active = true;
Telegram->SendMessage("@username", "hello from Delphi");
官方 TDLib(tdjson)共享库的 Delphi 外观——与官方 Telegram 客户端使用相同的协议。
组件驱动 TDLib 身份验证状态机:电话号码、验证码、可选的双因素验证密码,并将会话持久保存在本地数据库目录中。
SendMessage、SendPhoto、SendVideo、SendDocument、SendVoiceNote 及其他类型化方法涵盖 TDLib 消息内容类型。
GetChats、GetChat、SearchPublicChat 和 GetUser 以类型化响应的形式公开 Telegram 通讯录和已加入的频道/群组。
OnTelegramUpdate 以原始 JSON 形式传递每个 TDLib updateXxx 事件——新消息、用户输入、频道帖子、编辑、删除——供下游路由使用。
使用官方 tdjson.dll / libtdjson.so / libtdjson.dylib——与官方 Telegram 客户端相同的端到端加密保障。
TDLib 支持 Windows、macOS、Linux、Android 和 iOS。按平台配置 LibraryPath;组件为您处理类型化的桥接。
本组件实现的 API 的权威来源。