// ----------------------------------------------------------------------------------- // ver 1.2 / Nov 23, 2020, (c) Alexey Pikurov, support@nsoft-s.com // ----------------------------------------------------------------------------------- function OnPrivateMessage(iCID, iUIN, iUINTo, iMsgType: integer; sMsg: string): boolean; var sID, sOutMsg, sNameFrom, s: string; bResult: boolean; begin SetScriptTimeOut(10000); result := true; if not mIsUINOnline(iUINTo) then begin // get sender's Telegram ID sID := mIntegrationTelegramGetUserIDByUIN(iUINTo); if sID[1] <> '-' then begin // no errors // get MyChat sender's display name sNameFrom := mGetUserFullNameByPreset(iUIN, 0); if (iMsgType = 2) or (iMsgType = 23) then sOutMsg := mExtractExternalWebLinkFromMessage(sMsg, iMsgType) else // convert MyChat message to plaint text sOutMsg := mConvertMsgToPlainText(sMsg, iMsgType); // add WEB support link and user display name to message sOutMsg := '' + sNameFrom + ':' + CRLF + CRLF + sOutMsg; // send message to Telegram s := mIntegrationTelegramSendMessage(sID, sOutMsg, 5000); bResult := true; if JSONGetBoolean(s, 'ok', bResult) <> 0 then bResult := false; // if any error occured - log result to server's system scripts protocol if not bResult then begin s := 'From: ' + IntToStr(iUIN) + ', to: ' + IntToStr(iUINTo) + CRLF + s; mLogScriptToDisk(s); end; end; end; end; begin end.