Skip to content

Commit

Permalink
update js.abr
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelustosa committed Sep 22, 2023
1 parent 8f656eb commit f7b569f
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 51 deletions.
Binary file removed CEF_files/CEF_OLD_VERSIONS/91.1.22/CEF4Bin.rar
Binary file not shown.
Binary file not shown.
Binary file added Demo/TInject.res
Binary file not shown.
3 changes: 2 additions & 1 deletion Demo/u_principal.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object frmPrincipal: TfrmPrincipal
Top = 3
Width = 1096
Height = 527
ActivePage = TabSheet1
ActivePage = TabSheet3
Align = alClient
TabOrder = 0
ExplicitWidth = 1092
Expand Down Expand Up @@ -5525,6 +5525,7 @@ object frmPrincipal: TfrmPrincipal
OnGetQrCode = TInject1GetQrCode
OnGetChatList = TInject1GetChatList
OnGetUnReadMessages = TInject1GetUnReadMessages
OnGetUnReadMessagesFromMe = TInject1GetUnReadMessagesFromMe
OnGetAllGroupContacts = TInject1GetAllGroupContacts
OnGetStatus = TInject1GetStatus
OnGetBatteryLevel = TInject1GetBatteryLevel
Expand Down
56 changes: 56 additions & 0 deletions Demo/u_principal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ TfrmPrincipal = class(TForm)
procedure btSendTextButtonClick(Sender: TObject);
procedure TInject1GetIncomingCall(const incomingCall: TReturnIncomingCall);
procedure btSendButtonListClick(Sender: TObject);
procedure TInject1GetUnReadMessagesFromMe(const Chats: TChatList);

private
{ Private declarations }
Expand Down Expand Up @@ -1218,6 +1219,60 @@ procedure TfrmPrincipal.TInject1GetUnReadMessages(Const Chats: TChatList);
contato, telefone: string;
injectDecrypt: TInjectDecryptFile;
begin
{ for AChat in Chats.result do
begin
for AMessage in AChat.messages do
begin
if not AChat.isGroup then //Não exibe mensages de grupos
begin
if not AMessage.fromMe then //Não exibe mensages enviadas por mim
begin
memo_unReadMessage.Clear;
//Tratando o tipo do arquivo recebido e faz o download para pasta \BIN\temp
case AnsiIndexStr(UpperCase(AMessage.&type), ['PTT', 'IMAGE', 'VIDEO', 'AUDIO', 'DOCUMENT']) of
0: begin injectDecrypt.download(AMessage.deprecatedMms3Url, AMessage.mediaKey, 'mp3', AChat.id); end;
1: begin injectDecrypt.download(AMessage.deprecatedMms3Url, AMessage.mediaKey, 'jpg', AChat.id); end;
2: begin injectDecrypt.download(AMessage.deprecatedMms3Url, AMessage.mediaKey, 'mp4', AChat.id); end;
3: begin injectDecrypt.download(AMessage.deprecatedMms3Url, AMessage.mediaKey, 'mp3', AChat.id); end;
4: begin injectDecrypt.download(AMessage.deprecatedMms3Url, AMessage.mediaKey, 'pdf', AChat.id); end;
end;
sleepNoFreeze(100);
memo_unReadMessage.Lines.Add(PChar( 'Nome Contato: ' + Trim(AMessage.Sender.pushName)));
memo_unReadMessage.Lines.Add(PChar( 'Chat Id : ' + AChat.id));
FChatID := AChat.id;
memo_unReadMessage.Lines.Add(PChar('Tipo mensagem: ' + AMessage.&type));
memo_unReadMessage.Lines.Add( StringReplace(AMessage.body, #$A, #13#10, [rfReplaceAll, rfIgnoreCase]));
telefone := Copy(AChat.id, 3, Pos('@', AChat.id) - 3);
contato := AMessage.Sender.pushName;
ed_profilePicThumbURL.text := AChat.contact.profilePicThumb;
TInject1.ReadMessages(AChat.id);
if chk_AutoResposta.Checked then
VerificaPalavraChave(AMessage.body, '', telefone, contato);
end;
end;
end;
end; }
end;

procedure TfrmPrincipal.TInject1GetUnReadMessagesFromMe(const Chats: TChatList);
var
AChat: TChatClass;
AMessage: TMessagesClass;
contato, telefone: string;
injectDecrypt: TInjectDecryptFile;
AJSONChat :TJSONObject;
begin

AJSONChat := TJSONValue.ParseJSONValue(Chats.jsonString) as TJSONObject;

for AChat in Chats.result do
begin
for AMessage in AChat.messages do
Expand Down Expand Up @@ -1259,6 +1314,7 @@ procedure TfrmPrincipal.TInject1GetUnReadMessages(Const Chats: TChatList);
end;
end;
end;

end;

procedure TfrmPrincipal.TInject1IsConnected(Sender: TObject;
Expand Down
33 changes: 23 additions & 10 deletions Source/JS/js.abr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Version_JS;Version_TInjectMin;Version_CEF4Min;
//2.0.1.0;1.0.0.9;78.3.0
//2.0.2.0;1.0.0.9;78.3.0
//

function getAllGroupContacts(Contacts) {
Expand Down Expand Up @@ -61,13 +61,16 @@ function SetConsoleMessage(jsName, resultValue) {
var intervalMonitor;
var isLoggedStatus = false;
var gettingUnreadMessages = false;
var WAVersion;

function startMonitor(intervalSeconds = 0) {
isLoggedStatus = WAPI.isLoggedIn();
window.WAPI.onIncomingCall();
window.WAPI.onGetUnReadMessageFromMe();

if (intervalSeconds >= 1) {
WAVersion = WAPI.getWAVersion();
WAVersion = WAVersion.replace(/\./g, '');

if (intervalSeconds >= 1) {
intervalMonitor = window.setInterval(monitorUnReadMessages, intervalSeconds * 1000);
}
}
Expand Down Expand Up @@ -1575,13 +1578,23 @@ window.WAPI.sendImage = function(imgBase64, chatid, filename, caption) {
var mediaBlob = window.WAPI.base64ImageToFile(imgBase64, filename);
var mc = new Store.MediaCollection(chat);


//New - Mike Lustosa 07/06/2022
mc.processAttachments([{file: mediaBlob}, 1], chat, 1).then(() => {
let media = mc._models[0];
media.sendToChat(chat, {caption:caption});
return true;
});
console.log('WAVersion: ', WAVersion);

if (WAVersion >= 223409) {
mc.processAttachments([{file: mediaBlob}, 1], 1, chat).then(() => {
let media = mc._models[0];
media.sendToChat(chat, {caption:caption});
return true;
});

} else {
mc.processAttachments([{file: mediaBlob}, 1], chat, 1).then(() => {
let media = mc._models[0];
media.sendToChat(chat, {caption:caption});
return true;
});
}

});

}
Expand Down
69 changes: 50 additions & 19 deletions Source/Model/uTInject.Constant.pas
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

interface

Uses Winapi.Messages, System.SysUtils, typinfo, REST.Json;
Uses Winapi.Messages, System.SysUtils, typinfo, REST.Json, StrUtils, EncdDecd;

Const
//Uso GLOBAL
//Version updates I=HIGH, II=MEDIUM, III=LOW, IV=VERY LOW
TInjectVersion = '4.0.0.0'; // 31/07/2023 //Alterado por Mike Lustosa
TInjectVersion = '4.0.1.0'; // 05/08/2023 //Alterado por Mike Lustosa
CardContact = '@c.us';
CardGroup = '@g.us';
CardList = '@broadcast';
Expand Down Expand Up @@ -247,29 +247,30 @@ interface

TTypeHeader = (Th_None = 0,
//Eventos de Retornos
Th_GetAllContacts=1, Th_GetAllChats=2, Th_GetUnreadMessages=3, Th_GetAllGroupContacts=4,
Th_GetBatteryLevel=5, Th_GetQrCodeForm=6, Th_GetQrCodeWEB=7,
Th_GetMyNumber=8, Th_OnChangeConnect=9, Th_getIsDelivered=10,
Th_GetReserv2=11, Th_GetReserv3=12, Th_GetReserv4=13,
Th_GetReserv5=14, Th_GetReserv6=15, Th_GetReserv7=16,
Th_GetCheckIsValidNumber=17, Th_GetCheckIsConnected=18, Th_GetProfilePicThumb=19, Th_getAllGroups=20, Th_getAllGroupAdmins=21,
Th_GetAllContacts=1, Th_GetAllChats=2, Th_GetUnreadMessages=3, Th_getUnreadMessagesFromMe=4, Th_GetAllGroupContacts=5,
Th_GetBatteryLevel=6, Th_GetQrCodeForm=7, Th_GetQrCodeWEB=8,
Th_GetMyNumber=9, Th_OnChangeConnect=10, Th_getIsDelivered=11,
Th_GetReserv2=12, Th_GetReserv3=13, Th_GetReserv4=14,
Th_GetReserv5=15, Th_GetReserv6=16, Th_GetReserv7=17,
Th_GetCheckIsValidNumber=18, Th_GetCheckIsConnected=19, Th_GetProfilePicThumb=20, Th_getAllGroups=21, Th_getAllGroupAdmins=22,

//Eventos Conexao
Th_Disconnected=22, Th_Disconnecting=23, Th_Connected=24,
Th_ConnectedDown=25, Th_Connecting=26, Th_ConnectingFt_Desktop=27,
Th_ConnectingFt_HTTP=28, Th_ConnectingNoPhone=29, Th_Destroy=30,
Th_Destroying=31, Th_NewSyncContact=32, Th_Initializing=33,
Th_Initialized=34, Th_Abort=35, Th_ForceDisconnect=36,
Th_AlterConfig=37,

Th_GetStatusMessage=38, Th_GetGroupInviteLink=39, Th_GetMe=40, Th_NewCheckIsValidNumber=41, Th_GetIncomingCall=42
Th_Disconnected=23, Th_Disconnecting=24, Th_Connected=25,
Th_ConnectedDown=26, Th_Connecting=27, Th_ConnectingFt_Desktop=28,
Th_ConnectingFt_HTTP=29, Th_ConnectingNoPhone=30, Th_Destroy=31,
Th_Destroying=32, Th_NewSyncContact=33, Th_Initializing=34,
Th_Initialized=35, Th_Abort=36, Th_ForceDisconnect=37,
Th_AlterConfig=38,

Th_GetStatusMessage=39, Th_GetGroupInviteLink=40, Th_GetMe=41, Th_NewCheckIsValidNumber=42, Th_GetIncomingCall=43
);

Function VerificaCompatibilidadeVersao(PVersaoExterna:String; PversaoInterna:String):Boolean;
Function FrmConsole_JS_AlterVar(var PScript:String; PNomeVar: String; Const PValor:String):String;
function StrToTypeHeader(PText: string): TTypeHeader;
Procedure SleepNoFreeze(PTimeOut:Integer);
Function StrExtFile_Base64Type(PFileName: String): String;
function FileToBase64_(const fileName: string): string;

implementation

Expand Down Expand Up @@ -339,14 +340,44 @@ implementation
End;


function FileToBase64_(const fileName: string): string;
var
FileStream: TFileStream;
MemoryStream: TMemoryStream;
mimeType: string;
begin
FileStream := TFileStream.Create(fileName, fmOpenRead);
MemoryStream := TMemoryStream.Create;
try
MemoryStream.CopyFrom(FileStream, 0);
mimeType := StrExtFile_Base64Type(fileName);

Result := mimeType + EncodeBase64(MemoryStream.Memory, MemoryStream.Size);
finally
MemoryStream.Free;
FileStream.Free;
end;
end;


Function StrExtFile_Base64Type(PFileName: String): String;
var
I: Integer;
LExt: String;
Ltmp: String;
Begin
LExt := LowerCase(Copy(ExtractFileExt(PFileName),2,50));

case AnsiIndexStr(LExt, ['mp4', 'mp3', 'ogg', 'avi', 'mpeg']) of
0: begin result := 'data:application/mp4;base64,'; exit; end;
1: begin result := 'data:audio/mp3;base64,'; exit; end;
2: begin result := 'data:audio/ogg;base64,'; exit; end;
3: begin result := 'data:video/avi;base64,'; exit; end;
4: begin result := 'data:video/mpeg;base64,'; exit; end;
end;

Result := 'data:application/';

try
for I := 0 to 6 do
begin
Expand All @@ -369,12 +400,12 @@ implementation
end;

finally
Result := Result + LExt + ';base64,' ;
Result := Result + LExt + ';base64,' ;
end;
End;

function StrToTypeHeader(PText: string): TTypeHeader;
const LmaxCount = 42;
function StrToTypeHeader(PText: string): TTypeHeader;
const LmaxCount = 43;
var
I: Integer;
LNome: String;
Expand Down
18 changes: 15 additions & 3 deletions Source/Services/uTInject.pas
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface
TOnGetCheckIsValidNumber = Procedure(Sender : TObject; Number: String; IsValid: Boolean) of object;
TOnGetProfilePicThumb = Procedure(Sender : TObject; Base64: String) of object;
TGetUnReadMessages = procedure(Const Chats: TChatList) of object;
TGetUnReadMessagesFromMe = procedure(Const Chats: TChatList) of object;
TOnGetQrCode = procedure(Const Sender: Tobject; Const QrCode: TResultQRCodeClass) of object;
TOnAllContacts = procedure(Const AllContacts: TRetornoAllContacts) of object;
TOnAllGroups = procedure(Const AllGroups: TRetornoAllGroups) of object;
Expand Down Expand Up @@ -107,6 +108,7 @@ TInject = class(TComponent)
protected
{ Protected declarations }
FOnGetUnReadMessages : TGetUnReadMessages;
FOnGetUnReadMessagesFromMe : TGetUnReadMessagesFromMe;
FOnGetAllGroupContacts : TOnAllGroupContacts;
FOnGetAllContactList : TOnAllContacts;
FOnGetAllGroupList : TOnAllGroups;
Expand Down Expand Up @@ -221,6 +223,7 @@ TInject = class(TComponent)
property OnGetQrCode : TOnGetQrCode read FOnGetQrCode write FOnGetQrCode;
property OnGetChatList : TGetUnReadMessages read FOnGetChatList write FOnGetChatList;
property OnGetUnReadMessages : TGetUnReadMessages read FOnGetUnReadMessages write FOnGetUnReadMessages;
property OnGetUnReadMessagesFromMe : TGetUnReadMessagesFromMe read FOnGetUnReadMessagesFromMe write FOnGetUnReadMessagesFromMe;
property OnGetAllGroupContacts : TOnAllGroupContacts read FOnGetAllGroupContacts write FOnGetAllGroupContacts;
property OnGetStatus : TNotifyEvent read FOnGetStatus write FOnGetStatus;
property OnGetBatteryLevel : TNotifyEvent read FOnGetBatteryLevel write FOnGetBatteryLevel;
Expand Down Expand Up @@ -1081,7 +1084,7 @@ procedure TInject.Int_OnNotificationCenter(PTypeHeader: TTypeHeader; PValue: Str
end;


if (PTypeHeader In [Th_GetAllChats, Th_getUnreadMessages]) then
if (PTypeHeader In [Th_GetAllChats, Th_getUnreadMessages, Th_getUnreadMessagesFromMe]) then
Begin
if not Assigned(PReturnClass) then
raise Exception.Create(MSG_ExceptMisc + ' in Int_OnNotificationCenter' );
Expand All @@ -1099,6 +1102,13 @@ procedure TInject.Int_OnNotificationCenter(PTypeHeader: TTypeHeader; PValue: Str

end;

If PTypeHeader = Th_getUnreadMessagesFromMe Then
Begin
if Assigned(OnGetUnReadMessagesFromMe) then
OnGetUnReadMessagesFromMe(TChatList(PReturnClass));

end;

Exit;
end;

Expand Down Expand Up @@ -1342,9 +1352,8 @@ procedure TInject.send(PNumberPhone, PMessage: string; PEtapa: string = '');
lThread.Start;
end;


procedure TInject.SendFile(PNumberPhone: string;
const PFileName: String; PMessage: string);
const PFileName: String; PMessage: string = '');
var
lThread : TThread;
LStream : TMemoryStream;
Expand Down Expand Up @@ -1373,6 +1382,7 @@ procedure TInject.SendFile(PNumberPhone: string;

LStream := TMemoryStream.Create;
LBase64File := TBase64Encoding.Create;

try
try
LStream.LoadFromFile(PFileName);
Expand Down Expand Up @@ -1404,6 +1414,8 @@ procedure TInject.SendFile(PNumberPhone: string;
begin
FrmConsole.ReadMessages(PNumberPhone); //Marca como lida a mensagem
FrmConsole.sendBase64(LBase64, PNumberPhone, PFileName, PMessage);
//FrmConsole.sendBase64(PFileName, PNumberPhone, PFileName, PMessage);

end;
end);
end);
Expand Down
Loading

0 comments on commit f7b569f

Please sign in to comment.