Cliente TDLib de Telegram
Crea aplicaciones de cuenta de usuario o bot de Telegram en Delphi/C++Builder. Envuelve la TDLib oficial de Telegram para exponer autenticación, chats, mensajes y eventos de actualización.
Crea aplicaciones de cuenta de usuario o bot de Telegram en Delphi/C++Builder. Envuelve la TDLib oficial de Telegram para exponer autenticación, chats, mensajes y eventos de actualización.
Wrapper Delphi/C++Builder para la TDLib oficial de Telegram (tdjson). Gestiona la máquina de estados de autenticación, expone eventos tipados de envío y recepción de mensajes, y entrega el resto de actualizaciones de TDLib a través de OnEvent.
TsgcTDLib_Telegram
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
Establece Telegram.API.ApiId / ApiHash y Telegram.PhoneNumber, engancha OnAuthenticationCode para el flujo de inicio de sesión y envía mensajes cuando OnAuthorizationStatus informe authorizationStateReady.
uses
sgcLibs;
var
Telegram: TsgcTDLib_Telegram;
begin
Telegram := TsgcTDLib_Telegram.Create(nil);
Telegram.Telegram.API.ApiId := '123456';
Telegram.Telegram.API.ApiHash := 'your-api-hash';
Telegram.Telegram.PhoneNumber := '+34600111222';
Telegram.OnAuthenticationCode := TelegramAuthenticationCode;
Telegram.OnAuthorizationStatus := TelegramAuthorizationStatus;
Telegram.OnMessageText := TelegramMessageText;
Telegram.Active := True;
end;
procedure TForm1.TelegramAuthenticationCode(Sender: TObject;
var Code: string);
begin
Code := InputBox('Telegram', 'Enter the code you received', '');
end;
procedure TForm1.TelegramAuthorizationStatus(Sender: TObject;
const Status: string);
begin
if Status = 'authorizationStateReady' then
Telegram.GetChats;
end;
procedure TForm1.TelegramMessageText(Sender: TObject;
MessageText: TsgcTelegramMessageText);
begin
Memo1.Lines.Add(MessageText.ChatId + ': ' + MessageText.Text);
Telegram.SendTextMessage(MessageText.ChatId, 'received!');
end;
// include: sgcLibs.hpp
TsgcTDLib_Telegram *Telegram = new TsgcTDLib_Telegram(this);
Telegram->Telegram->API->ApiId = "123456";
Telegram->Telegram->API->ApiHash = "your-api-hash";
Telegram->Telegram->PhoneNumber = "+34600111222";
Telegram->OnAuthenticationCode = TelegramAuthenticationCode;
Telegram->OnAuthorizationStatus = TelegramAuthorizationStatus;
Telegram->OnMessageText = TelegramMessageText;
Telegram->Active = true;
void __fastcall TForm1::TelegramAuthenticationCode(TObject *Sender, AnsiString &Code)
{
Code = InputBox("Telegram", "Enter the code you received", "");
}
void __fastcall TForm1::TelegramAuthorizationStatus(TObject *Sender, const AnsiString Status)
{
if (Status == "authorizationStateReady")
Telegram->GetChats();
}
void __fastcall TForm1::TelegramMessageText(TObject *Sender, TsgcTelegramMessageText *MessageText)
{
Memo1->Lines->Add(MessageText->ChatId + ": " + MessageText->Text);
Telegram->SendTextMessage(MessageText->ChatId, "received!");
}
Una fachada Delphi sobre la librería compartida oficial TDLib (tdjson) — el mismo protocolo que utilizan los clientes oficiales de Telegram.
El componente conduce la máquina de estados de autenticación de TDLib: número de teléfono, código, contraseña 2FA opcional y persiste la sesión en el directorio de base de datos local.
SendTextMessage, SendPhotoMessage, SendVideoMessage, SendDocumentMessage y SendMessageAlbum cubren los principales tipos de contenido de mensaje de TDLib.
GetChats, GetChat, SearchPublicChat y GetUser exponen la agenda de Telegram y los canales/grupos a los que te has unido como respuestas tipadas.
OnEvent entrega cada evento updateXxx de TDLib — nuevos mensajes, usuario escribiendo, publicaciones de canal, ediciones, borrados — como nombre de evento en bruto más JSON para enrutar a tu lógica, junto con los eventos tipados OnMessageText, OnNewChat y OnNewCallbackQuery para los casos habituales.
Usa la oficial tdjson.dll / libtdjson.so / libtdjson.dylib — las mismas garantías de cifrado end-to-end que el cliente oficial de Telegram.
TDLib se distribuye para Windows, macOS, Linux, Android e iOS. El componente localiza y carga la librería nativa automáticamente según la plataforma; tú solo gestionas el bridging tipado mediante los eventos y métodos anteriores.
Fuentes oficiales de la API que este componente implementa.
Enlace directo a la referencia del componente, descarga el proyecto demo listo para ejecutar y consigue la prueba gratuita.
| Ayuda en línea — API_Telegram Referencia completa de propiedades, métodos y eventos de este componente. | Abrir | |
| Proyecto demo — Demos\50.Other\01.Telegram_Client Proyecto de ejemplo listo para ejecutar. Se incluye dentro del paquete sgcWebSockets Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.mdash; descarga la prueba a continuación. | Abrir | |
| Documento técnico (PDF) Características, inicio rápido, ejemplos de código para Delphi y C++ Builder y referencias a fuentes primarias Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.mdash; solo de este componente. | Abrir | |
| Manual de usuario (PDF) Manual completo que cubre todos los componentes de la librería. | Abrir |