Today, we are releasing MyChat 8.4. Please update and replace your old script with this one! 
 
 Here is the latest version of the script — 2.1. 
Code: Select all// -----------------------------------------------------------------------------------
// ver 2.1 / Feb 1, 2021, (c) Alexey Pikurov, [email protected]
// -----------------------------------------------------------------------------------
function OnRequestByREST(sBody, sParams, sHeaders, sURL, sIPv4, sIPv6: string; iType: integer): string;
var
  sFirstName, sLastName, sNickName, sTelegramID, sText, sData: string;
  iResult, x, iUIN, iUINFrom: integer;
begin
  sFirstName  := '';
  sLastName   := '';
  sNickName   := '';
  sTelegramID := '';
  sText       := '';
  
  // get request data
  JSONGetString(sBody, 'message.from.id', sTelegramID);
  JSONGetString(sBody, 'message.from.first_name', sFirstName);
  JSONGetString(sBody, 'message.from.last_name', sLastName);
  JSONGetString(sBody, 'message.from.username', sNickName);
  JSONGetString(sBody, 'message.text', sText);
    // if user is connecting to the Telegram bot for the first time
    if LowerCase(sText) = '/start' then mIntegrationTelegramAddUser(sTelegramID, sFirstName, sLastName, sNickName)
      else begin // maybe user send reply message to the bot
        iResult := JSONGetString(sBody, 'message.reply_to_message.entities[0].url', sData);
        
          if iResult = 0 then begin
            // get receiver's UIN
            x := pos('?uin=', sData) + 5;
            iUIN := StrToIntDef(copy(sData, x, pos('&', sData) - x), -1);
            // get sender's UIN by user Telegram ID
            iUINFrom := mIntegrationTelegramGetMyChatUINByTelegramID(sTelegramID);
              // if sender and receiver are exists
              if (iUIN <> -1) and (iUINFrom > 0) then begin
                if Length(sText) > 0 then begin
                  // multi-line text
                  sData := '[Telegram] ' + ReplaceString(sText, #10, CRLF, true, false); 
                  // send private message into MyChat
                  mSendPrivateMessage(iUINFrom, iUIN, sData, 1);
                end else begin
             JSONSetInteger(sBody, 'UINFrom', iUINFrom);
                  JSONSetInteger(sBody, 'UINTo',   iUIN);
                  mNodeCommand('GetTelegramAttach', sBody);
                end
              end;  
          end;
      
      end;
      
  result := '{}';
end;
begin
end.
 
					
					
					real human bean