MyChat Scripts Engine: mIntegrationTelegramSendMessage, send a message from MyChat to Telegram
Send a message to the Telegram bot from MyChat.
Syntax
function mIntegrationTelegramSendMessage(sTelegramID, sText: string; iTimeOut: integer): integer;
Parameters and return values
Parameter |
Type |
Value |
sTelegramID |
string |
Telegram user text ID; |
sText |
string |
message text; |
iTimeOut |
integer |
maximum time for query execution in milliseconds. |
Function result
-1 |
integration between MyChat and Telegram is disabled. Message sending is impossible; |
-2 |
Telegram bot ID specified incorrectly or is not specified at all; |
-3 |
Telegram user ID is not specified |
Example
const
iUIN = 6;
var
sID, sMsg, sNameFrom: string;
begin
// get sender's Telegram ID
sID := mIntegrationTelegramGetUserIDByUIN(iUIN);
if sID[1] <> '-' then begin // no errors
sMsg := 'Hello, world!';
// send message to Telegram
mIntegrationTelegramSendMessage(sID, sMsg, 5000);
end;
end.
Script work result
[19:58:32] (Log "SendMessage2Telegram"): [Telegram] {"ok":true,"result":{"message_id":51,"from":{"id":384707904,"first_name":"Test","username":"Test_mc11111_bot"},"chat":{"id":384912421,"first_name":"Alexey","last_name":"Pikurov","type":"private"},"date":1496854712,"text":"Hello, world!","entities":[{"type":"bold","offset":0,"length":5},{"type":"italic","offset":7,"length":5}]}}
[19:58:32] (Run "SendMessage2Telegram"): Script operation time: 8 ms
[19:58:32] (Run "SendMessage2Telegram"): Script done successfully.
See also
Using HTML tags to format messages to Telegram
mIntegrationTelegramGetUserIDByUIN
Created with the Personal Edition of HelpNDoc: Step-by-Step Guide: How to Turn Your Word Document into an eBook