eSeGeCe
software
From sgcWebSockets 4.4.6, the telegram client has been improved to support send messages with buttons (only supported when you login as a bot).
The methods to send a message have been modified to add a new parameter where you can send the Callback and URL Buttons.
Before you send a message create an instance of the class TsgcTelegramReplyMarkupInlineKeyboard and call the method AddButtonTypeCallback or AddButtonTypeUrl for every button you want to create.
Create a new message asking the user if likes or not the message. Process the response using OnNewCallbackQuery event.
oReplyMarkup := TsgcTelegramReplyMarkupInlineKeyboard.Create;
Try
oReplyMarkup.AddButtonTypeCallback('Yes', 'I like it');
oReplyMarkup.AddButtonTypeCallback('No', 'I hate it');
sgcTelegram.SendTextMessage('123456', 'Do you like the message?', oReplyMarkup);
Finally
oReplyMarkup.Free;
End;
procedure OnNewCallbackQuery(Sender: TObject; CallbackQuery: TsgcTelegramCallbackQuery);
begin
if CallbackQuery.PayLoadData.Data = 'I like it' then
ShowMessage('yes')
else
ShowMessage('no');
end;
Create a new message like Button Callback and now add a button which will open a new page to answer a poll.
oReplyMarkup := TsgcTelegramReplyMarkupInlineKeyboard.Create;
Try
oReplyMarkup.AddButtonTypeCallback('Yes', 'I like it');
oReplyMarkup.AddButtonTypeCallback('No', 'I hate it');
oReplyMarkup.AddButtonTypeUrl('Poll', 'https://www.yoursite.com/telegram/poll');
sgcTelegram.SendTextMessage('123456', 'Do you like the message?', oReplyMarkup);
Finally
oReplyMarkup.Free;
End;
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.