UNPKG

@necrotry/necrotry-js

Version:
1 lines 9.4 kB
const _0x172e5f=_0x4ba3;function _0x3dbd(){const _0x391f15=['ndxxi','findOne','dbGVs','GWKhZ','updateOne','save_inter','.json','mongo_url','Schema','3462TrdmyQ','use_mongo','25FYJBYV','data','1|5|2|4|0|','yuvwW','utf-8','_model','tOKKA','nFile','vOiOb','delete','File','debug','ion','THmNd','schema','model','1816746HSQVdq','585cFwIeG','name','TDtsM','Invalid\x20cr','YXAqw','function','376132SUEfCf','MongoDB','all','DRXxh','parse','CocjV','11716420NYXFLt','isValidJso','groups','abase...','split','ized','efjcs','users','KXwGV','initialize','get','clear','asCyl','schedule','125884lFQvak','createJson','group','cxSMB','riodically','validate','set','saveDataPe','2950236PlUyrz','connect','getTasks','error','MJjRH','1176424paBajc','uGkHt','./database','val','on\x20express','stringify','14vHTSFu','settings','oAVie','cron','hasInitial','runExclusi','9|6|8|7|3|','_database','OPJvR','isExist','Saving\x20dat','JaGKe','release','cWasn'];_0x3dbd=function(){return _0x391f15;};return _0x3dbd();}(function(_0x52ec0c,_0x5c9805){const _0x49a6b3=_0x4ba3,_0x528d9a=_0x52ec0c();while(!![]){try{const _0x48ec16=-parseInt(_0x49a6b3(0x16f))/(0x21e1+-0x258a+0x3aa)+-parseInt(_0x49a6b3(0x142))/(-0x1d84+-0x9f*0x1f+0x30c7*0x1)*(parseInt(_0x49a6b3(0x155))/(-0x109d*0x1+-0x81b+-0x1e7*-0xd))+-parseInt(_0x49a6b3(0x15b))/(0x1*0xc0a+-0x2c*-0xad+-0x1*0x29c2)*(-parseInt(_0x49a6b3(0x144))/(0x5*-0x4d1+-0x198a+0x18d2*0x2))+-parseInt(_0x49a6b3(0x154))/(-0x12c8+0xa8d*0x2+-0x24c)+-parseInt(_0x49a6b3(0x12b))/(0x2*0x24b+-0x11e8+-0xd59*-0x1)*(parseInt(_0x49a6b3(0x125))/(-0x67*-0x22+-0x19a2+-0xec*-0xd))+-parseInt(_0x49a6b3(0x120))/(0x52*0x5f+0x68a+-0x24ef)+parseInt(_0x49a6b3(0x161))/(-0x343+0x152e*0x1+-0xc7*0x17);if(_0x48ec16===_0x5c9805)break;else _0x528d9a['push'](_0x528d9a['shift']());}catch(_0x5837c2){_0x528d9a['push'](_0x528d9a['shift']());}}}(_0x3dbd,-0x5a5*-0x22+-0x1*0x35c0f+0x67b12));import{readFileSync,writeFileSync,existsSync}from'fs';function _0x4ba3(_0x5a9b59,_0x5353b9){const _0x182a99=_0x3dbd();return _0x4ba3=function(_0x5cd38e,_0x3c3a4d){_0x5cd38e=_0x5cd38e-(0xbc3*0x2+0x3*-0xde+-0x13d2);let _0x3abf1f=_0x182a99[_0x5cd38e];return _0x3abf1f;},_0x4ba3(_0x5a9b59,_0x5353b9);}import{Mutex}from'async-mutex';import _0x65e80f from'mongoose';import _0x47eab6 from'node-cron';import{UserDatabase,GroupDatabase,SettingsDatabase}from'../../../../System/Database.js';class Crons{constructor(_0x238793,_0x3f4285,_0x491764){const _0x1dbfd0=_0x4ba3,_0xbf64f1={'dbGVs':function(_0x173284,_0x237917){return _0x173284??_0x237917;}};this[_0x1dbfd0(0x156)]=_0x238793,this[_0x238793]=_0xbf64f1[_0x1dbfd0(0x13b)](_0x3f4285,{}),this[_0x1dbfd0(0x152)]=_0x491764;}[_0x172e5f(0x11d)](_0x14bd51){const _0x5f39a2=_0x172e5f;return _0x47eab6[_0x5f39a2(0x11d)](_0x14bd51);}[_0x172e5f(0x16e)](_0x3d550b,_0x4691ba,_0x1d9215){const _0x5b392a=_0x172e5f,_0x290321={'GWKhZ':function(_0x4a02a6,_0x561295){return _0x4a02a6(_0x561295);},'ndxxi':_0x5b392a(0x158)+_0x5b392a(0x129)+_0x5b392a(0x150)};if(!_0x47eab6[_0x5b392a(0x11d)](_0x3d550b))throw new Error(_0x290321[_0x5b392a(0x139)]);_0x47eab6[_0x5b392a(0x16e)](_0x3d550b,async()=>{const _0x32ebfb=_0x5b392a;_0x290321[_0x32ebfb(0x13c)](_0x4691ba,this[this[_0x32ebfb(0x156)]]);},_0x1d9215);}[_0x172e5f(0x122)](){const _0x5830c0=_0x172e5f;return _0x47eab6[_0x5830c0(0x122)]();}}class Helper{constructor(_0x3f7235,_0x32828d,_0x5a1cc5){const _0x40a04c=_0x172e5f,_0x218465={'asCyl':function(_0x2ebe62,_0x3835c4){return _0x2ebe62??_0x3835c4;}};this[_0x40a04c(0x156)]=_0x3f7235,this[_0x3f7235]=_0x218465[_0x40a04c(0x16d)](_0x32828d,{}),this[_0x40a04c(0x152)]=_0x5a1cc5,this[_0x40a04c(0x12e)]=new Crons(_0x3f7235,this[_0x3f7235],this[_0x40a04c(0x152)]);}[_0x172e5f(0x16b)](_0x57c41c){const _0x7d496a=_0x172e5f;return this[this[_0x7d496a(0x156)]][_0x57c41c]??null;}[_0x172e5f(0x11e)](_0x2a0061){const _0x5cf6ae=_0x172e5f,_0x1acd16={'JaGKe':function(_0x5a7106,_0x2c7a4e){return _0x5a7106===_0x2c7a4e;},'DRXxh':_0x5cf6ae(0x15a)};if(this[this[_0x5cf6ae(0x156)]][_0x2a0061])return this[this[_0x5cf6ae(0x156)]][_0x2a0061];this[this[_0x5cf6ae(0x156)]][_0x2a0061]={};for(const _0x392239 in this[_0x5cf6ae(0x152)]){this[this[_0x5cf6ae(0x156)]][_0x2a0061][_0x392239]=_0x1acd16[_0x5cf6ae(0x136)](typeof this[_0x5cf6ae(0x152)][_0x392239],_0x1acd16[_0x5cf6ae(0x15e)])?this[_0x5cf6ae(0x152)][_0x392239]():this[_0x5cf6ae(0x152)][_0x392239];}return this[this[_0x5cf6ae(0x156)]][_0x2a0061];}[_0x172e5f(0x134)](_0x4503f9){const _0x4626c0=_0x172e5f;return this[this[_0x4626c0(0x156)]][_0x4503f9]?!![]:![];}[_0x172e5f(0x14d)](_0x42f7eb){const _0x25aad6=_0x172e5f;delete this[this[_0x25aad6(0x156)]][_0x42f7eb];}[_0x172e5f(0x15d)](){const _0x230e08=_0x172e5f;return this[this[_0x230e08(0x156)]];}[_0x172e5f(0x16c)](){const _0x93f3ad=_0x172e5f;this[this[_0x93f3ad(0x156)]]={};}}class Database{#initialized=![];#path='./'+global?.[_0x172e5f(0x132)]?.['db']+_0x172e5f(0x13f)??_0x172e5f(0x127)+_0x172e5f(0x13f);#data={'users':{},'groups':{},'settings':{}};#mutex=new Mutex();constructor(){const _0x20eeaa=_0x172e5f;this[_0x20eeaa(0x149)]=null;}#write(_0x368dff=global?.[_0x172e5f(0x132)]?.[_0x172e5f(0x14f)],_0xeaffd4=global?.[_0x172e5f(0x132)]?.[_0x172e5f(0x143)]){const _0x187842=_0x172e5f,_0x51b8e0={'cxSMB':_0x187842(0x135)+_0x187842(0x164),'MJjRH':function(_0x351585,_0x5f94e4,_0x4b21d4){return _0x351585(_0x5f94e4,_0x4b21d4);}};this.#mutex[_0x187842(0x130)+'ve'](async()=>{const _0x2c7e09=_0x187842;_0x368dff&&console[_0x2c7e09(0x14f)](_0x51b8e0[_0x2c7e09(0x11b)]);try{_0xeaffd4&&(this[_0x2c7e09(0x149)]&&await this[_0x2c7e09(0x149)][_0x2c7e09(0x13d)]({},this.#data,{'upsert':!![]})),_0x51b8e0[_0x2c7e09(0x124)](writeFileSync,this.#path,JSON[_0x2c7e09(0x12a)](this.#data,null,-0x17a2+0x1f4f+-0x7ab));}catch(_0xea81e4){console[_0x2c7e09(0x123)](_0xea81e4);}finally{this.#mutex[_0x2c7e09(0x137)]();}});}async[_0x172e5f(0x16a)](_0x42e9b0=global?.[_0x172e5f(0x132)]?.[_0x172e5f(0x143)]){const _0x2630a2=_0x172e5f,_0x5e4e18={'CocjV':_0x2630a2(0x131)+_0x2630a2(0x146)+'10','efjcs':_0x2630a2(0x12c),'cWasn':_0x2630a2(0x168),'yuvwW':_0x2630a2(0x11a),'YXAqw':function(_0x1056cd,_0x1b018e,_0x18ef8e){return _0x1056cd(_0x1b018e,_0x18ef8e);},'oAVie':_0x2630a2(0x148),'tOKKA':function(_0x115b75,_0x2b6e66){return _0x115b75(_0x2b6e66);}},_0x157b56=_0x5e4e18[_0x2630a2(0x160)][_0x2630a2(0x165)]('|');let _0x47ec8d=-0x6*-0x447+0x23b3*0x1+-0x17*0x2ab;while(!![]){switch(_0x157b56[_0x47ec8d++]){case'0':this[_0x2630a2(0x12c)]=new Helper(_0x5e4e18[_0x2630a2(0x167)],this.#data[_0x2630a2(0x12c)],SettingsDatabase);continue;case'1':this.#data[_0x2630a2(0x163)]=this.#data[_0x2630a2(0x163)]??{};continue;case'2':this[_0x2630a2(0x168)]=new Helper(_0x5e4e18[_0x2630a2(0x138)],this.#data[_0x2630a2(0x168)],UserDatabase);continue;case'3':this.#data[_0x2630a2(0x168)]=this.#data[_0x2630a2(0x168)]??{};continue;case'4':this[_0x2630a2(0x163)]=new Helper(_0x5e4e18[_0x2630a2(0x147)],this.#data[_0x2630a2(0x163)],GroupDatabase);continue;case'5':this.#data[_0x2630a2(0x12c)]=this.#data[_0x2630a2(0x12c)]??{};continue;case'6':_0x42e9b0&&await this[_0x2630a2(0x16a)+_0x2630a2(0x15c)]();continue;case'7':this.#data=JSON[_0x2630a2(0x15f)](_0x5e4e18[_0x2630a2(0x159)](readFileSync,this.#path,_0x5e4e18[_0x2630a2(0x12d)]));continue;case'8':(!_0x5e4e18[_0x2630a2(0x14a)](existsSync,this.#path)||!this[_0x2630a2(0x162)+_0x2630a2(0x14b)]())&&await this[_0x2630a2(0x170)+_0x2630a2(0x14e)]();continue;case'9':if(this.#initialized)return;continue;case'10':this.#initialized=!![];continue;}break;}}async[_0x172e5f(0x16a)+_0x172e5f(0x15c)](_0x27f771=global?.[_0x172e5f(0x132)]?.[_0x172e5f(0x140)]){const _0x57f9a8=_0x172e5f,_0x5ed52e={'vOiOb':_0x57f9a8(0x145)};try{await _0x65e80f[_0x57f9a8(0x121)](_0x27f771,{'useNewUrlParser':!![],'useUnifiedTopology':!![]});const _0x1c3ae0=new _0x65e80f[(_0x57f9a8(0x141))]({'users':Object,'groups':Object,'settings':Object});this[_0x57f9a8(0x149)]=_0x65e80f[_0x57f9a8(0x153)](_0x5ed52e[_0x57f9a8(0x14c)],_0x1c3ae0);}catch(_0x3f149d){throw new Error(_0x3f149d);}}[_0x172e5f(0x162)+_0x172e5f(0x14b)](){const _0x6d364f=_0x172e5f,_0x54c67b={'uGkHt':function(_0x4268f0,_0x1b00f3,_0x5cd0cc){return _0x4268f0(_0x1b00f3,_0x5cd0cc);},'TDtsM':_0x6d364f(0x148)},_0x44c9fb=_0x54c67b[_0x6d364f(0x126)](readFileSync,this.#path,_0x54c67b[_0x6d364f(0x157)]);try{return JSON[_0x6d364f(0x15f)](_0x44c9fb),!![];}catch(_0x33f11c){return![];}}async[_0x172e5f(0x170)+_0x172e5f(0x14e)](_0x413dac=global?.[_0x172e5f(0x132)]?.[_0x172e5f(0x143)]){const _0x38c293=_0x172e5f,_0x2dba52={'OPJvR':function(_0x53a21e,_0xce41b8,_0x470e12){return _0x53a21e(_0xce41b8,_0x470e12);},'THmNd':function(_0xd0d7c4,_0x412a52,_0x521ce1){return _0xd0d7c4(_0x412a52,_0x521ce1);}};if(_0x413dac&&this[_0x38c293(0x149)]){const _0x1e135a=await this[_0x38c293(0x149)][_0x38c293(0x13a)]();if(_0x1e135a){_0x2dba52[_0x38c293(0x133)](writeFileSync,this.#path,JSON[_0x38c293(0x12a)](_0x1e135a,null,-0x400+-0x26c6+0x4*0xab2));return;}}_0x2dba52[_0x38c293(0x151)](writeFileSync,this.#path,JSON[_0x38c293(0x12a)]({}));}[_0x172e5f(0x11f)+_0x172e5f(0x11c)](_0x50a041=global?.[_0x172e5f(0x132)]?.[_0x172e5f(0x13e)+_0x172e5f(0x128)]??-0xb46+-0x8c1+-0x871*-0x7){const _0x58e533=_0x172e5f,_0x1d5c14={'KXwGV':function(_0x9c7ed,_0x464c79,_0x12f653){return _0x9c7ed(_0x464c79,_0x12f653);}};_0x1d5c14[_0x58e533(0x169)](setInterval,()=>{this.#write();},_0x50a041);}get[_0x172e5f(0x12f)+_0x172e5f(0x166)](){return this.#initialized;}}const data=new Database();global['db']=data;export default data;