Files
NapCatQQ/src/core.lib/src/apis/file.js
T
2024-05-15 11:40:25 +08:00

1 line
10 KiB
JavaScript

const _0x2365fe=_0x4a3b;(function(_0x45e3ac,_0x529208){const _0x41b2fa=_0x4a3b,_0x57eeae=_0x45e3ac();while(!![]){try{const _0x4d64ca=-parseInt(_0x41b2fa(0x123))/0x1*(-parseInt(_0x41b2fa(0x128))/0x2)+-parseInt(_0x41b2fa(0x130))/0x3+-parseInt(_0x41b2fa(0xe8))/0x4*(parseInt(_0x41b2fa(0xfb))/0x5)+parseInt(_0x41b2fa(0x111))/0x6*(-parseInt(_0x41b2fa(0xff))/0x7)+-parseInt(_0x41b2fa(0x104))/0x8+parseInt(_0x41b2fa(0xf1))/0x9+parseInt(_0x41b2fa(0x10b))/0xa;if(_0x4d64ca===_0x529208)break;else _0x57eeae['push'](_0x57eeae['shift']());}catch(_0x42805f){_0x57eeae['push'](_0x57eeae['shift']());}}}(_0x4390,0xb7f0c));import{ElementType,IMAGE_HTTP_HOST,IMAGE_HTTP_HOST_NT}from'@/core/entities';import _0x1b1c13 from'path';import _0x179165 from'fs';import _0x245f4c from'fs/promises';import{logDebug}from'@/common/utils/log';function _0x4390(){const _0x1cc8b6=['YmxJw','addCacheScannedPaths','9106500lEVEwu','AasVB','addCacheScanedPaths','uploadFile','downloadMedia\x20complete','getImageSize','113814qVMpOc','hotUpdate','CMinv','getRichMediaFilePathForGuild','basename','copyFile','sPTiO','RWodP','sOkYb','filePath','downloadPath','indexOf','BeCJI','unlink','aiNPx','fileTypeFromFile','JvShJ','toUpperCase','2ijMJjr','getMsgService','getFileType','getFileCacheInfo','shbpG','379198etdfvn','/gchatpic_new/0/0-0-','&rkey=','getFileSize','msgId','startsWith','getHotUpdateCachePath','delete','650868QGkHNy','WSMUE','onRichMediaDownloadComplete','start\x20downloadMedia','RQjeR','clearCacheDataByKeys','clearCache','FvgYe','setCacheSilentScan','1344ZNPjiS','gEtGW','downloadMedia','kxExd','cxwTR','XCgVk','existsSync','tmp','set','7166907cNkcAF','DEvmr','YKSRn','clearChatCache','private_rkey','downloadRichMedia','PIC','getStorageCleanService','hsJVh','scanCache','8490DRAzJr','onLoginSuccess','clearChatCacheInfo','getRkey','77boDEiW','Piant','ext','util','join','2692864JbmSBp','session','hBGRU','ZlLEl','PAEYS'];_0x4390=function(){return _0x1cc8b6;};return _0x4390();}import{napCatCore}from'@/core';import{calculateFileMD5}from'@/common/utils/file';import*as _0x295c3c from'file-type';import{MsgListener}from'@/core/listeners';import _0x4e2797 from'image-size';import{sessionConfig}from'@/core/sessionConfig';import{randomUUID}from'crypto';import{rkeyManager}from'../utils/rkey';import{AsyncQueue}from'@/common/utils/AsyncQueue';const getRKeyTaskQueue=new AsyncQueue(),downloadMediaTasks=new Map(),downloadMediaListener=new MsgListener();downloadMediaListener[_0x2365fe(0xe1)]=_0x31d3ee=>{const _0x3e78c1=_0x2365fe,_0x429d10={'RQjeR':function(_0x25da46,_0xdccd7c){return _0x25da46(_0xdccd7c);}};for(const [_0x2c56ff,_0x17fe20]of downloadMediaTasks){_0x429d10[_0x3e78c1(0xe3)](_0x17fe20,_0x31d3ee),downloadMediaTasks[_0x3e78c1(0x12f)](_0x2c56ff);}},setTimeout(()=>{const _0x1243ef=_0x2365fe;napCatCore[_0x1243ef(0xfc)](()=>{napCatCore['addListener'](downloadMediaListener);});},0x64);export class NTQQFileApi{static async[_0x2365fe(0x125)](_0x18442c){const _0xbcc05b=_0x2365fe;return _0x295c3c[_0xbcc05b(0x120)](_0x18442c);}static async['copyFile'](_0x3172fd,_0x3f07fe){const _0x55130b=_0x2365fe;await napCatCore[_0x55130b(0x102)][_0x55130b(0x116)](_0x3172fd,_0x3f07fe);}static async['getFileSize'](_0x49bfa9){const _0x29b309=_0x2365fe;return await napCatCore[_0x29b309(0x102)][_0x29b309(0x12b)](_0x49bfa9);}static async[_0x2365fe(0x10e)](_0x380f91,_0x5bd6c0=ElementType[_0x2365fe(0xf7)],_0x5d7ce8=0x0){const _0x4b5195=_0x2365fe,_0x1cae90={'GCXLh':function(_0x33f39a,_0x163cb9){return _0x33f39a(_0x163cb9);},'oiJhd':function(_0x594592,_0x228817){return _0x594592+_0x228817;},'AasVB':function(_0x2ec477,_0x143b88){return _0x2ec477===_0x143b88;}},_0x337a05=await _0x1cae90['GCXLh'](calculateFileMD5,_0x380f91);let _0xdf9492=(await NTQQFileApi[_0x4b5195(0x125)](_0x380f91))?.[_0x4b5195(0x101)]||'';_0xdf9492&&(_0xdf9492=_0x1cae90['oiJhd']('.',_0xdf9492));let _0x17247e=''+_0x1b1c13[_0x4b5195(0x115)](_0x380f91);_0x1cae90[_0x4b5195(0x10c)](_0x17247e[_0x4b5195(0x11c)]('.'),-0x1)&&(_0x17247e+=_0xdf9492);const _0x34135b=napCatCore[_0x4b5195(0x105)][_0x4b5195(0x124)]()[_0x4b5195(0x114)]({'md5HexStr':_0x337a05,'fileName':_0x17247e,'elementType':_0x5bd6c0,'elementSubType':_0x5d7ce8,'thumbSize':0x0,'needCreate':!![],'downloadType':0x1,'file_uuid':''});await NTQQFileApi['copyFile'](_0x380f91,_0x34135b);const _0x2a56bb=await NTQQFileApi[_0x4b5195(0x12b)](_0x380f91);return{'md5':_0x337a05,'fileName':_0x17247e,'path':_0x34135b,'fileSize':_0x2a56bb,'ext':_0xdf9492};}static async[_0x2365fe(0xea)](_0xe1f2f6,_0x5740df,_0xb64a37,_0xceddbe,_0x3bd7c1,_0x489a01,_0x4ac7ad=0x3e8*0x3c*0x2,_0x41bf3a=![]){const _0x217edc=_0x2365fe,_0x307257={'DEvmr':'下载超时','BeCJI':function(_0x486bd3,_0x563ca4,_0x547a9d,_0x1a7dba){return _0x486bd3(_0x563ca4,_0x547a9d,_0x1a7dba);},'kxExd':function(_0x3745ee,_0x361b3d){return _0x3745ee===_0x361b3d;},'gEtGW':_0x217edc(0x11b),'RWodP':function(_0x16f28c,_0x4ef7ab){return _0x16f28c(_0x4ef7ab);},'YmxJw':function(_0x4ff679){return _0x4ff679();},'shbpG':function(_0x1193f5,_0x134ee4,_0x5b304a,_0x17483c,_0x54057e,_0x36aa51,_0x4c9852,_0x1e8081,_0x41f312,_0x95e748){return _0x1193f5(_0x134ee4,_0x5b304a,_0x17483c,_0x54057e,_0x36aa51,_0x4c9852,_0x1e8081,_0x41f312,_0x95e748);},'VzrEL':'receive\x20downloadMedia\x20task','hsJVh':_0x217edc(0xe2)};_0x307257[_0x217edc(0x127)](logDebug,_0x307257['VzrEL'],_0xe1f2f6,_0x5740df,_0xb64a37,_0xceddbe,_0x3bd7c1,_0x489a01,_0x4ac7ad,_0x41bf3a);if(_0x489a01&&_0x179165[_0x217edc(0xee)](_0x489a01)){if(_0x41bf3a)try{await _0x245f4c[_0x217edc(0x11e)](_0x489a01);}catch(_0x11c014){}else return _0x489a01;}return _0x307257[_0x217edc(0x127)](logDebug,_0x307257[_0x217edc(0xf9)],_0xe1f2f6,_0x5740df,_0xb64a37,_0xceddbe,_0x3bd7c1,_0x489a01,_0x4ac7ad,_0x41bf3a),new Promise((_0x13410d,_0x6ce39c)=>{const _0x588e2b=_0x217edc,_0x427804={'aiNPx':function(_0x293756,_0x1c7d4f,_0x308821,_0x2e8ca0){const _0x2884ac=_0x4a3b;return _0x307257[_0x2884ac(0x11d)](_0x293756,_0x1c7d4f,_0x308821,_0x2e8ca0);},'PAEYS':_0x588e2b(0x10f),'CMinv':function(_0xbe4c1,_0xd3f9f0){const _0x3e1cbf=_0x588e2b;return _0x307257[_0x3e1cbf(0xeb)](_0xbe4c1,_0xd3f9f0);},'sPTiO':function(_0x15cb35,_0x1a5bbe,_0x6a2b35){return _0x15cb35(_0x1a5bbe,_0x6a2b35);},'XCgVk':_0x307257[_0x588e2b(0xe9)],'hBGRU':function(_0x23eacc,_0x174e81){const _0x46b20a=_0x588e2b;return _0x307257[_0x46b20a(0x118)](_0x23eacc,_0x174e81);}};let _0x2de9ed=![];const _0x378070=_0x546d3a=>{const _0x419a3e=_0x588e2b;_0x427804[_0x419a3e(0x11f)](logDebug,_0x427804[_0x419a3e(0x108)],_0x546d3a,_0xe1f2f6);if(_0x427804[_0x419a3e(0x113)](_0x546d3a[_0x419a3e(0x12c)],_0xe1f2f6)){_0x2de9ed=!![];let _0x1a6652=_0x546d3a[_0x419a3e(0x11a)];if(_0x1a6652[_0x419a3e(0x12d)]('\x5c')){const _0x4613a5=sessionConfig['defaultFileDownloadPath'];_0x427804[_0x419a3e(0x117)](logDebug,_0x427804[_0x419a3e(0xed)],_0x4613a5),_0x1a6652=_0x1b1c13[_0x419a3e(0x103)](_0x4613a5,_0x1a6652);}_0x427804[_0x419a3e(0x106)](_0x13410d,_0x1a6652);}};downloadMediaTasks[_0x588e2b(0xf0)](_0x307257[_0x588e2b(0x109)](randomUUID),_0x378070),setTimeout(()=>{const _0x34a9e=_0x588e2b;!_0x2de9ed&&_0x6ce39c(_0x307257[_0x34a9e(0xf2)]);},_0x4ac7ad),napCatCore[_0x588e2b(0x105)][_0x588e2b(0x124)]()[_0x588e2b(0xf6)]({'fileModelId':'0','downloadSourceType':0x0,'triggerType':0x1,'msgId':_0xe1f2f6,'chatType':_0x5740df,'peerUid':_0xb64a37,'elementId':_0xceddbe,'thumbSize':0x0,'downloadType':0x1,'filePath':_0x3bd7c1});});}static async[_0x2365fe(0x110)](_0x70fd82){const _0x169454={'ACizO':function(_0x1de248,_0x4987e7){return _0x1de248(_0x4987e7);},'ZlLEl':function(_0x33e341,_0x3e477d){return _0x33e341(_0x3e477d);}};return new Promise((_0x11ae69,_0x44e84a)=>{const _0x5ebc15={'cxwTR':function(_0x40409c,_0x1fa0c3){return _0x169454['ACizO'](_0x40409c,_0x1fa0c3);},'FvgYe':function(_0x3c3f71,_0x1e5fdf){const _0xb6580c=_0x4a3b;return _0x169454[_0xb6580c(0x107)](_0x3c3f71,_0x1e5fdf);}};_0x4e2797(_0x70fd82,(_0x2309da,_0x195542)=>{const _0x706dd9=_0x4a3b;_0x2309da?_0x5ebc15[_0x706dd9(0xec)](_0x44e84a,_0x2309da):_0x5ebc15[_0x706dd9(0xe6)](_0x11ae69,_0x195542);});});}static async['getImageUrl'](_0x1687a9,_0x24a4f7){const _0x22bd40=_0x2365fe,_0x4db90b={'Piant':'/download','GHwBE':_0x22bd40(0x12a),'JvShJ':function(_0x19c789,_0x2918c0){return _0x19c789+_0x2918c0;},'WSMUE':function(_0x508476,_0x57d229){return _0x508476+_0x57d229;},'YKSRn':function(_0x248614,_0x2cbf0d){return _0x248614||_0x2cbf0d;},'sOkYb':function(_0x1a3d59,_0x11081d,_0x47fd99){return _0x1a3d59(_0x11081d,_0x47fd99);},'cuDax':'图片url获取失败'};if(!_0x1687a9)return'';const _0x5cf583=_0x1687a9['originImageUrl'],_0x1cecc4=_0x1687a9['md5HexStr'],_0x15f192=_0x1687a9['md5HexStr'],_0x5bf822=_0x1687a9['fileUuid'];if(_0x5cf583){if(_0x5cf583[_0x22bd40(0x12d)](_0x4db90b[_0x22bd40(0x100)])){if(_0x5cf583['includes'](_0x4db90b['GHwBE']))return _0x4db90b[_0x22bd40(0x121)](IMAGE_HTTP_HOST_NT,_0x5cf583);const _0x55a861=await rkeyManager[_0x22bd40(0xfe)](),_0x5d3804=_0x24a4f7?_0x55a861[_0x22bd40(0xf5)]:_0x55a861['group_rkey'];return _0x4db90b[_0x22bd40(0x121)](_0x4db90b['JvShJ'](IMAGE_HTTP_HOST_NT,_0x5cf583),''+_0x5d3804);}else return _0x4db90b[_0x22bd40(0x131)](IMAGE_HTTP_HOST,_0x5cf583);}else{if(_0x15f192||_0x1cecc4)return IMAGE_HTTP_HOST+_0x22bd40(0x129)+_0x4db90b[_0x22bd40(0xf3)](_0x15f192,_0x1cecc4)[_0x22bd40(0x122)]()+'/0';}return _0x4db90b[_0x22bd40(0x119)](logDebug,_0x4db90b['cuDax'],_0x1687a9),'';}}function _0x4a3b(_0x4707be,_0x47aaab){const _0x439037=_0x4390();return _0x4a3b=function(_0x4a3be8,_0x1f05e8){_0x4a3be8=_0x4a3be8-0xe1;let _0x5d1cea=_0x439037[_0x4a3be8];return _0x5d1cea;},_0x4a3b(_0x4707be,_0x47aaab);}export class NTQQFileCacheApi{static async[_0x2365fe(0xe7)](_0x3769a6=!![]){return'';}static['getCacheSessionPathList'](){return'';}static[_0x2365fe(0xe5)](_0x40a04d=[_0x2365fe(0xef),_0x2365fe(0x112)]){const _0x20a081=_0x2365fe;return napCatCore['session'][_0x20a081(0xf8)]()[_0x20a081(0xe4)](_0x40a04d);}static[_0x2365fe(0x10a)](_0x6ded9e={}){const _0x2c0394=_0x2365fe;return napCatCore['session'][_0x2c0394(0xf8)]()[_0x2c0394(0x10d)](_0x6ded9e);}static[_0x2365fe(0xfa)](){const _0x13773c=_0x2365fe;return napCatCore[_0x13773c(0x105)][_0x13773c(0xf8)]()[_0x13773c(0xfa)]();}static[_0x2365fe(0x12e)](){return'';}static['getDesktopTmpPath'](){return'';}static['getChatCacheList'](_0x3b7696,_0xefab1d=0x3e8,_0x51f303=0x0){const _0x3888a1=_0x2365fe;return napCatCore[_0x3888a1(0x105)][_0x3888a1(0xf8)]()['getChatCacheInfo'](_0x3b7696,_0xefab1d,0x1,_0x51f303);}static[_0x2365fe(0x126)](_0x3a7574,_0x178988=0x3e8,_0x19c369){const _0xac465b=_0x19c369?_0x19c369:{'fileType':_0x3a7574};}static async[_0x2365fe(0xf4)](_0x2c0ead=[],_0x3c5d6c=[]){const _0x39bb1d=_0x2365fe;return napCatCore[_0x39bb1d(0x105)][_0x39bb1d(0xf8)]()[_0x39bb1d(0xfd)](_0x2c0ead,_0x3c5d6c);}}