
Ini adalah komponen Delphi untuk berinteraksi dengan API Bot Telegram. Ini menyediakan serangkaian fungsi untuk melakukan berbagai tindakan menggunakan platform bot telegram.
Untuk menggunakan komponen ini dalam proyek Delphi Anda, ikuti langkah -langkah ini:
DTelegram.dproj yang terletak di folder "paket" dari kode sumber komponen.DTelegram.bpl . Langkah ini mungkin melibatkan klik kanan pada file proyek dan memilih "kompilasi" dan kemudian "instal." | Fungsi | Keterangan | Contoh penggunaan |
|---|---|---|
| GetMe | Dapatkan informasi tentang bot. | BotInfo := TelegramBot.GetMe; |
| Logout | Keluar dari bot. | LoggedOut := TelegramBot.LogOut; |
| Menutup | Tutup koneksi bot. | Closed := TelegramBot.Close; |
| Sendmessage | Kirim pesan teks. | Message := TelegramBot.SendMessage(ChatId, 'Hello, Telegram!'); |
| ForwardMessage | Meneruskan pesan. | ForwardedMessage := TelegramBot.ForwardMessage(TargetChatId, SourceChatId, MessageId); |
| Copymessage | Salin pesan. | CopiedMessageId := TelegramBot.CopyMessage(TargetChatId, SourceChatId, MessageId); |
| Sendphoto | Kirim foto. | PhotoMessage := TelegramBot.SendPhoto(ChatId, 'path/to/photo.jpg', 'Check this out!'); |
| Sendaudio | Kirim file audio. | AudioMessage := TelegramBot.SendAudio(ChatId, 'path/to/audio.mp3', 'Listen to this!'); |
| Senddocument | Kirim dokumen. | DocumentMessage := TelegramBot.SendDocument(ChatId, 'path/to/document.pdf'); |
| Sendvideo | Kirim video. | VideoMessage := TelegramBot.SendVideo(ChatId, 'path/to/video.mp4'); |
| Sendanimation | Kirim Animasi (GIF). | AnimationMessage := TelegramBot.SendAnimation(ChatId, 'path/to/animation.gif'); |
| Sendvoice | Kirim pesan suara. | VoiceMessage := TelegramBot.SendVoice(ChatId, 'path/to/voice.ogg'); |
| SendVideonote | Kirim catatan video. | VideoNoteMessage := TelegramBot.SendVideoNote(ChatId, 'path/to/videonote.mp4'); |
| Sendlocation | Kirim lokasi. | LocationMessage := TelegramBot.SendLocation(ChatId, Latitude, Longitude); |
| Sendvenue | Kirim tempat. | VenueMessage := TelegramBot.SendVenue(ChatId, Latitude, Longitude, 'Venue Title', 'Venue Address'); |
| Sendcontact | Kirim kontak. | ContactMessage := TelegramBot.SendContact(ChatId, '123456789', 'John Doe'); |
| Sendpoll | Kirim jajak pendapat. | PollMessage := TelegramBot.SendPoll(ChatId, 'Which is your favorite color?', ['Red', 'Green', 'Blue']); |
| Senddice | Kirim dadu. | DiceMessage := TelegramBot.SendDice(ChatId, '?'); |
| Getupdates | Dapatkan pembaruan dari server. | Updates := TelegramBot.GetUpdates(100, -1, 0); |
| GetFile | Dapatkan informasi tentang file. | FileInfo := TelegramBot.GetFile(FileId); |
| Banchatmember | Larang anggota obrolan. | Banned := TelegramBot.BanChatMember(ChatId, UserId); |
| Unbanchatmember | Unban seorang anggota obrolan. | UnBanned := TelegramBot.UnBanChatMember(ChatId, UserId); |
| CreateChatInVitelink | Buat tautan undangan obrolan. | InviteLink := TelegramBot.CreateChatInviteLink(ChatId); |
| RevokeChatInvitelink | Mencabut tautan undangan obrolan. | RevokedLink := TelegramBot.RevokeChatInviteLink(ChatId, 'your_invite_link'); |
| ExportChatInvitelink | Ekspor tautan undangan obrolan. | ExportedLink := TelegramBot.ExportChatInviteLink(ChatId); |
| AcprovechatjoinRequest | Menyetujui permintaan bergabung dengan obrolan. | Approved := TelegramBot.ApproveChatJoinRequest(ChatId, UserId); |
| DeclinechatjoinRequest | Menolak permintaan bergabung dengan obrolan. | Declined := TelegramBot.DeclineChatJoinRequest(ChatId, UserId); |
| Deletechatphoto | Hapus foto obrolan. | PhotoDeleted := TelegramBot.DeleteChatPhoto(ChatId); |
| SetChattitle | Atur judul obrolan. | TitleSet := TelegramBot.SetChatTitle(ChatId, 'New Title'); |
| SetChatDescription | Atur deskripsi obrolan. | DescriptionSet := TelegramBot.SetChatDescription(ChatId, 'New Description'); |
| LeaveChat | Tinggalkan obrolan. | LeftChat := TelegramBot.LeaveChat(ChatId); |
| Getchat | Dapatkan informasi tentang obrolan. | ChatInfo := TelegramBot.GetChat(ChatId); |
| SetMyname | Atur nama bot. | NameSet := TelegramBot.SetMyName('New Bot Name'); |
| GetMyname | Dapatkan nama bot. | BotName := TelegramBot.GetMyName(); |
| SetMyDescription | Atur deskripsi bot. | DescriptionSet := TelegramBot.SetMyDescription('New Bot Description'); |
| GetMydescription | Dapatkan deskripsi bot. | BotDescription := TelegramBot.GetMyDescription(); |
| GeninlineKeyboard | Keyboard Balas | Response := TelegramBot.GenInlineKeyBoard(AButtonList,NumberOfButtonPerRow); |
Anda perlu membuat bot sebelum menggunakan komponen ini.
Untuk saluran publik sangat mudah untuk menemukan chatidnya.
Ex : https://t.me/abcdefg - > ChatId := @abcdefg;Dapatkan informasi tentang bot.
var BotInfo := TelegramBot.GetMe;Keluar dari bot.
var LoggedOut := TelegramBot.LogOut;Tutup koneksi bot.
var Closed := TelegramBot.Close;Kirim pesan teks.
var Message := TelegramBot.SendMessage(ChatId, ' Hello, Telegram! ' );Meneruskan pesan.
var ForwardedMessage := TelegramBot.ForwardMessage(TargetChatId, SourceChatId, MessageId);Salin pesan.
var CopiedMessageId := TelegramBot.CopyMessage(TargetChatId, SourceChatId, MessageId);Kirim foto.
// How use AOptions
var AOption : TTelegramDic; // TDictionary<string,string>;
AOption := TTelegramDic.Create;
AOption.Add( ' protect_content ' , ' 1 ' ); // Example
var PhotoMessage := TelegramBot.SendPhoto(ChatId, ' path/to/photo.jpg ' , ' Check this out! ' ,AOption);Kirim file audio.
var AudioMessage := TelegramBot.SendAudio(ChatId, ' path/to/audio.mp3 ' , ' Listen to this! ' );Kirim dokumen.
var DocumentMessage := TelegramBot.SendDocument(ChatId, ' path/to/document.pdf ' );Kirim video.
var VideoMessage := TelegramBot.SendVideo(ChatId, ' path/to/video.mp4 ' );Kirim Animasi (GIF).
var AnimationMessage := TelegramBot.SendAnimation(ChatId, ' path/to/animation.gif ' );Kirim pesan suara.
var VoiceMessage := TelegramBot.SendVoice(ChatId, ' path/to/voice.ogg ' );Kirim catatan video.
var VideoNoteMessage := TelegramBot.SendVideoNote(ChatId, ' path/to/videonote.mp4 ' );Kirim lokasi.
var LocationMessage := TelegramBot.SendLocation(ChatId, Latitude, Longitude);Kirim tempat.
var VenueMessage := TelegramBot.SendVenue(ChatId, Latitude, Longitude, ' Venue Title ' , ' Venue Address ' );Kirim kontak.
var ContactMessage := TelegramBot.SendContact(ChatId, ' 123456789 ' , ' John Doe ' );Kirim jajak pendapat.
var ListAnswers := TStringList.Create;
ListAnswers.Add( ' Red ' );
ListAnswers.Add( ' Green ' );
ListAnswers.Add( ' Blue ' );
// How use Option Argument
var Option := TStringList.Create;
Option.Add( ' allows_multiple_answers=1 ' );
Option.Add( ' protect_content=true ' );
var PollMessage := TelegramBot.SendPoll(ChatId, ' Which is your favorite color? ' , ListAnswers,Option);Kirim dadu.
MyEmoji := TEmojiDice.Basketball;
var DiceMessage := TelegramBot.SendDice(ChatId, MyEmoji);Dapatkan pembaruan dari server.
// By Default : Limit = 100; OffSet = -1; TimeOut = 0
var Updates := TelegramBot.GetUpdates(limit,AOffSet,ATimeOut);
Dapatkan informasi tentang file.
var FileInfo := TelegramBot.GetFile(FileId);Larang anggota obrolan.
var Banned := TelegramBot.BanChatMember(ChatId, UserId);Unban seorang anggota obrolan.
var UnBanned := TelegramBot.UnBanChatMember(ChatId, UserId);Buat tautan undangan obrolan.
var InviteLink := TelegramBot.CreateChatInviteLink(ChatId);Mencabut tautan undangan obrolan.
var RevokedLink := TelegramBot.RevokeChatInviteLink(ChatId, ' your_invite_link ' );Ekspor tautan undangan obrolan.
var ExportedLink := TelegramBot.ExportChatInviteLink(ChatId);Menyetujui permintaan bergabung dengan obrolan.
var Approved := TelegramBot.ApproveChatJoinRequest(ChatId, UserId);Menolak permintaan bergabung dengan obrolan.
var Declined := TelegramBot.DeclineChatJoinRequest(ChatId, UserId);Hapus foto obrolan.
var PhotoDeleted := TelegramBot.DeleteChatPhoto(ChatId);Atur judul obrolan.
var TitleSet := TelegramBot.SetChatTitle(ChatId, ' New Title ' );Atur deskripsi obrolan.
var DescriptionSet := TelegramBot.SetChatDescription(ChatId, ' New Description ' );Tinggalkan obrolan.
var LeftChat := TelegramBot.LeaveChat(ChatId);Dapatkan informasi tentang obrolan.
var ChatInfo := TelegramBot.GetChat(ChatId);Atur nama bot.
var NameSet := TelegramBot.SetMyName( ' New Bot Name ' );Dapatkan nama bot.
var BotName := TelegramBot.GetMyName();Atur deskripsi bot.
var DescriptionSet := TelegramBot.SetMyDescription( ' New Bot Description ' );Dapatkan deskripsi bot.
var BotDescription := TelegramBot.GetMyDescription();Aktifkan keyboard inline untuk tindakan interaktif. Tombol dukungan keyboard inline yang dapat bekerja di belakang layar atau membuka antarmuka yang berbeda, termasuk tombol URL.
Menggunakan temojiconstants membutuhkan unit bagian ketiga https://github.com/aso14/delphi- unicode-emoji
// Example usage of Inline Keyboards
var
LButtonList : TList <TTelegramInlineKeyBoardButton>;
begin
LButtonList := TList<TTelegramInlineKeyBoardButton>.Create;
// Create Button without Emoji
var LButton1 := TTelegramInlineKeyBoardButton.Create;
LButton1.text := ' Delphi Telegram ' ;
LButton1.url := ' https://github.com/aso14/DTelegram ' ;
// Create Button with Emoji
var LButton2 := TTelegramInlineKeyBoardButton.Create;
LButton2.text := ' Delphi UI ' + TEmojiConstants.UpsideDownFace;
LButton2.url := ' https://t.me/delphui ' ;
var LButton3 := TTelegramInlineKeyBoardButton.Create;
LButton3.text := ' Youtube ' +TEmojiConstants.WinkingFace;
LButton3.url := ' https://www.youtube.com/@uidelphi ' ;
LButtonList.Add(LButton1);
LButtonList.Add(LButton2);
LButtonList.Add(LButton3);
// If ALimitValue = 3, the maximun number of Button per row will be 3
var Response := TelegramBot.GenInlineKeyBoard(LButtonList, 3 );
var Option := TStringList.Create;
Option.Add( ' reply_markup= ' +Response);
TelegramBot.SendMessage( ' @chatId ' , ' Text ' ,Option);
end ;Perpustakaan ini dirilis di bawah lisensi MIT.
Jangan ragu untuk berkontribusi, membuka masalah, atau memberikan umpan balik!