mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-27 05:36:40 +08:00
1 line
29 KiB
JavaScript
1 line
29 KiB
JavaScript
'use strict';const _0x271d47=_0x599f;(function(_0x271763,_0x2c04c9){const _0x370f8e=_0x599f,_0xc1576e=_0x271763();while(!![]){try{const _0x3aa0f0=-parseInt(_0x370f8e(0x1de))/0x1+parseInt(_0x370f8e(0x1af))/0x2+-parseInt(_0x370f8e(0x1f1))/0x3*(-parseInt(_0x370f8e(0x21b))/0x4)+-parseInt(_0x370f8e(0x24e))/0x5*(-parseInt(_0x370f8e(0x203))/0x6)+-parseInt(_0x370f8e(0x1fb))/0x7*(-parseInt(_0x370f8e(0x1bc))/0x8)+parseInt(_0x370f8e(0x1fa))/0x9+-parseInt(_0x370f8e(0x247))/0xa*(parseInt(_0x370f8e(0x238))/0xb);if(_0x3aa0f0===_0x2c04c9)break;else _0xc1576e['push'](_0xc1576e['shift']());}catch(_0x4700b6){_0xc1576e['push'](_0xc1576e['shift']());}}}(_0xcc22,0xabd2b));var __decorate=this&&this[_0x271d47(0x1d1)]||function(_0x12fd33,_0x2dc58d,_0xa7af5,_0x2f9257){const _0x3b2959=_0x271d47;var _0x3476ed=arguments['length'],_0x22ac26=_0x3476ed<0x3?_0x2dc58d:_0x2f9257===null?_0x2f9257=Object['getOwnPropertyDescriptor'](_0x2dc58d,_0xa7af5):_0x2f9257,_0x10e04b;if(typeof Reflect===_0x3b2959(0x1b0)&&typeof Reflect[_0x3b2959(0x1c4)]===_0x3b2959(0x20a))_0x22ac26=Reflect[_0x3b2959(0x1c4)](_0x12fd33,_0x2dc58d,_0xa7af5,_0x2f9257);else{for(var _0x5d2d53=_0x12fd33['length']-0x1;_0x5d2d53>=0x0;_0x5d2d53--)if(_0x10e04b=_0x12fd33[_0x5d2d53])_0x22ac26=(_0x3476ed<0x3?_0x10e04b(_0x22ac26):_0x3476ed>0x3?_0x10e04b(_0x2dc58d,_0xa7af5,_0x22ac26):_0x10e04b(_0x2dc58d,_0xa7af5))||_0x22ac26;}return _0x3476ed>0x3&&_0x22ac26&&Object[_0x3b2959(0x1e3)](_0x2dc58d,_0xa7af5,_0x22ac26),_0x22ac26;},__metadata=this&&this[_0x271d47(0x1fd)]||function(_0x5db6ae,_0xa07dd4){const _0x3febdd=_0x271d47;if(typeof Reflect===_0x3febdd(0x1b0)&&typeof Reflect[_0x3febdd(0x1df)]===_0x3febdd(0x20a))return Reflect[_0x3febdd(0x1df)](_0x5db6ae,_0xa07dd4);},__param=this&&this[_0x271d47(0x25b)]||function(_0x3f6982,_0x59d0b3){return function(_0x297803,_0x5f16b6){_0x59d0b3(_0x297803,_0x5f16b6,_0x3f6982);};};Object[_0x271d47(0x1e3)](exports,_0x271d47(0x20c),{'value':!![]}),exports[_0x271d47(0x1bb)]=void 0x0;const globalConfig_service_1=require(_0x271d47(0x1d2)),upload_service_1=require('../upload/upload.service'),common_1=require(_0x271d47(0x1f7)),axios_1=require(_0x271d47(0x1bf)),chatLog_service_1=require(_0x271d47(0x228)),balance_constant_1=require('../../common/constants/balance.constant'),utils_1=require('../../common/utils'),chatLog_entity_1=require(_0x271d47(0x212)),typeorm_1=require(_0x271d47(0x256)),typeorm_2=require(_0x271d47(0x204)),balance_entity_1=require(_0x271d47(0x1db)),fanyi_service_1=require('../fanyi/fanyi.service'),badwords_service_1=require('../badwords/badwords.service');function _0x599f(_0x321c04,_0x3926a4){const _0xcc22a5=_0xcc22();return _0x599f=function(_0x599f52,_0x2ea0f9){_0x599f52=_0x599f52-0x1ac;let _0x4bcc04=_0xcc22a5[_0x599f52];return _0x4bcc04;},_0x599f(_0x321c04,_0x3926a4);}let MjService=class MjService{constructor(_0x8ad9d4,_0x2771e6,_0x382219,_0x3886b9,_0x1802e0,_0x34b01f,_0x35eee6){const _0x34f348=_0x271d47;this[_0x34f348(0x1eb)]=_0x8ad9d4,this[_0x34f348(0x248)]=_0x2771e6,this['uploadService']=_0x382219,this['chatLogService']=_0x3886b9,this[_0x34f348(0x210)]=_0x1802e0,this['fanyiService']=_0x34b01f,this[_0x34f348(0x201)]=_0x35eee6,this['rateLimits']={},this[_0x34f348(0x1be)]=[],this['enlargeWorking']=[],this[_0x34f348(0x24d)]=0x0,this[_0x34f348(0x23a)]={};}async['mjDraw'](_0xda3728){const _0x4ac561=_0x271d47,{jobId:_0x2e2e6b,prompt:_0x5395ea,startTime:_0x23b5a6,userId:_0x2099b4}=_0xda3728;return console['log'](_0x4ac561(0x206),_0x4ac561(0x23f)),await new Promise(_0x27f685=>setTimeout(_0x27f685,0x1388)),{'a':0x1,'b':0x2};}async[_0x271d47(0x1d5)](_0x488cb1,_0x17412b){const _0x11b594=_0x271d47;await this[_0x11b594(0x1b3)](_0x17412b),await this[_0x11b594(0x201)][_0x11b594(0x1bd)](_0x488cb1['prompt'],_0x17412b[_0x11b594(0x23d)]['id']);const _0x1f48ef=_0x488cb1[_0x11b594(0x25c)];let _0x192044=_0x488cb1[_0x11b594(0x25c)];const {baiduFanyiAppId:_0x67adc6,baiduFanyiSecret:_0x566f0d}=await this[_0x11b594(0x210)][_0x11b594(0x235)]([_0x11b594(0x1da),_0x11b594(0x22d)]);_0x67adc6&&_0x566f0d&&(_0x192044=await this[_0x11b594(0x21c)][_0x11b594(0x237)](_0x1f48ef));const _0x17782d='['+(0x0,utils_1[_0x11b594(0x25d)])()+']',_0x449e28=_0x17782d+'\x20'+_0x192044;console[_0x11b594(0x24a)](_0x11b594(0x1c1),_0x17782d),console[_0x11b594(0x24a)]('prompt\x20-------->\x20\x20',_0x449e28);const _0x5f34d6=this[_0x11b594(0x1be)][_0x11b594(0x22f)](_0xb5915e=>_0xb5915e[_0x11b594(0x1f0)](_0x488cb1[_0x11b594(0x25c)]));if(_0x5f34d6)throw new common_1[(_0x11b594(0x1dc))](_0x11b594(0x1e0),common_1[_0x11b594(0x1c5)]['BAD_REQUEST']);if(this[_0x11b594(0x24d)]>=0x3)throw new common_1[(_0x11b594(0x1dc))]('当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...',common_1[_0x11b594(0x1c5)][_0x11b594(0x207)]);await this[_0x11b594(0x22e)](_0x17412b),this[_0x11b594(0x24d)]++,console[_0x11b594(0x24a)](_0x11b594(0x1ce)+_0x17412b[_0x11b594(0x23d)]['id']+_0x11b594(0x24b),this[_0x11b594(0x24d)]);try{const _0x4bf5ba=await this[_0x11b594(0x1eb)][_0x11b594(0x22f)]({'where':{'prompt':(0x0,typeorm_1[_0x11b594(0x1ea)])('%'+_0x449e28+'%')}}),_0x3ec962=_0x4bf5ba[_0x11b594(0x257)](_0x2d28c4=>_0x2d28c4[_0x11b594(0x214)]);this['drawWorking'][_0x11b594(0x23b)](_0x449e28);let _0x1190f6;const _0x536324=await this['sendDrawInteractions'](_0x449e28,_0x3ec962,_0x17782d);_0x536324?(console[_0x11b594(0x24a)]('历史中存在当前图片、直接获取!'),_0x1190f6=_0x536324):_0x1190f6=await this['pollForResult'](_0x449e28,_0x3ec962,_0x17782d);this['queueCount']--,this[_0x11b594(0x24d)]<0x0&&(this[_0x11b594(0x24d)]=0x0),console['log'](_0x11b594(0x1cc),this[_0x11b594(0x24d)]);const {id:_0x2b3534,content:_0x285c68,channel_id:_0x3676d2,attachments:attachments=[],timestamp:_0x4c5756}=_0x1190f6;if(!attachments[_0x11b594(0x21e)]||!attachments[0x0][_0x11b594(0x1b7)])throw new common_1[(_0x11b594(0x1dc))]('绘画失败',common_1[_0x11b594(0x1c5)][_0x11b594(0x207)]);const {filename:_0xce0c48,url:_0x4acf91,width:_0x5fa686,height:_0x5a333d,size:_0x1d43bf}=attachments[0x0];console['log']('拿到了远程地址:\x20',_0x4acf91);const _0x15150f=this[_0x11b594(0x210)][_0x11b594(0x235)](['mjNotSaveImg']);let _0x125e1a='';(!Number(_0x15150f)||Number(_0x15150f)===0x0)&&(_0x125e1a=await this['uploadService'][_0x11b594(0x223)]({'filename':_0xce0c48,'url':_0x4acf91}),console['log']('存入图片完成:\x20',_0x125e1a));const _0x3e43b4={'curIp':(0x0,utils_1[_0x11b594(0x233)])(_0x17412b),'userId':_0x17412b[_0x11b594(0x23d)]['id'],'type':balance_constant_1['DeductionKey'][_0x11b594(0x1ff)],'prompt':_0x449e28,'answer':_0x125e1a,'model':'mj','extend':this[_0x11b594(0x1d4)](JSON[_0x11b594(0x231)](_0x1190f6)),'message_id':_0x2b3534,'variationId':_0x2b3534,'upscaleId':_0x2b3534,'group':0x1,'isSaveImg':!Number(_0x15150f)||Number(_0x15150f)===0x0,'fileInfo':JSON[_0x11b594(0x231)]({'width':_0x5fa686,'height':_0x5a333d,'size':_0x1d43bf,'filename':_0xce0c48,'cosUrl':_0x125e1a})};return await this[_0x11b594(0x1ca)]['saveChatLog'](_0x3e43b4),await this[_0x11b594(0x225)](_0x17412b),this[_0x11b594(0x1be)]=this[_0x11b594(0x1be)][_0x11b594(0x1e9)](_0x3a31ff=>_0x3a31ff!==_0x488cb1[_0x11b594(0x25c)]),_0x125e1a;}catch(_0x5c98ad){this[_0x11b594(0x24d)]--,this['queueCount']<0x0&&(this[_0x11b594(0x24d)]=0x0),console[_0x11b594(0x24a)]('绘制图片任务异常中断\x20队列-1:\x20',this['queueCount']),this[_0x11b594(0x1be)]=this[_0x11b594(0x1be)]['filter'](_0x18084b=>_0x18084b!==_0x488cb1[_0x11b594(0x25c)]);throw new common_1[(_0x11b594(0x1dc))](_0x5c98ad[_0x11b594(0x255)],common_1[_0x11b594(0x1c5)]['BAD_REQUEST']);}}async[_0x271d47(0x1d9)](_0xe2e5e7,_0x1979ca){const _0x1eb184=_0x271d47;if(this[_0x1eb184(0x24d)]>=0x3)throw new common_1['HttpException']('当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...',common_1[_0x1eb184(0x1c5)][_0x1eb184(0x207)]);this['queueCount']++,console[_0x1eb184(0x24a)]('用户'+_0x1979ca[_0x1eb184(0x23d)]['id']+'开始请求放大图片\x20队列+1:\x20',this[_0x1eb184(0x24d)]);const {message_id:_0x501b24,orderId:_0x551baf}=_0xe2e5e7;try{const _0x28da1e=await this[_0x1eb184(0x1eb)][_0x1eb184(0x20e)]({'where':{'message_id':_0x501b24}});if(!_0x28da1e)throw new common_1[(_0x1eb184(0x1dc))]('历史记录中不存在当前图片、请确认您放大的图片是否存在',common_1[_0x1eb184(0x1c5)]['BAD_REQUEST']);const _0x550117=await this['chatLogEntity'][_0x1eb184(0x20e)]({'where':{'upscaleId':_0x501b24,'action':_0x1eb184(0x205),'orderId':_0x551baf}});if(_0x550117)throw new common_1[(_0x1eb184(0x1dc))](_0x1eb184(0x251),common_1[_0x1eb184(0x1c5)][_0x1eb184(0x207)]);const {prompt:_0x577446,extend:_0x1e0ad6}=_0x28da1e;let _0x40d861=null;try{_0x40d861=JSON[_0x1eb184(0x1ee)](_0x1e0ad6);}catch(_0x10d37c){_0x40d861=[];}const {components:components=[]}=_0x40d861;if(!components[_0x1eb184(0x21e)])throw new common_1[(_0x1eb184(0x1dc))](_0x1eb184(0x1f6),common_1[_0x1eb184(0x1c5)][_0x1eb184(0x207)]);const _0x5ba908=components[0x0][_0x1eb184(0x1b2)][_0x551baf-0x1],{custom_id:_0x34cc67}=_0x5ba908;console[_0x1eb184(0x24a)](_0x1eb184(0x24f),_0x34cc67);const _0x28af53={'message_id':_0x501b24,'custom_id':_0x34cc67,'prompt':_0x577446,'orderId':_0x551baf};await this[_0x1eb184(0x200)](_0x28af53),console[_0x1eb184(0x24a)](_0x1eb184(0x1f3));const _0x222909=await this['chatLogEntity'][_0x1eb184(0x22f)]({'where':{'prompt':(0x0,typeorm_1[_0x1eb184(0x1ea)])('%'+_0x577446+'%')}}),_0x12520c=_0x222909['map'](_0x10e851=>_0x10e851[_0x1eb184(0x214)]);console['log']('历史这些id已经被获取过了\x20不能拿了:\x20',_0x12520c);const _0xcb45f6=await this['pollForUpscaleResult'](_0x28af53,_0x12520c);this['queueCount']--,this[_0x1eb184(0x24d)]<0x0&&(this['queueCount']=0x0),console[_0x1eb184(0x24a)]('放大图片任务结束\x20队列-1:\x20',this[_0x1eb184(0x24d)]);const {id:_0x41e0a9,content:_0x595960,channel_id:_0x44db76,attachments:attachments=[],timestamp:_0x6025bc}=_0xcb45f6;if(!attachments[_0x1eb184(0x21e)]||!attachments[0x0][_0x1eb184(0x1b7)])throw new common_1[(_0x1eb184(0x1dc))](_0x1eb184(0x1ba),common_1[_0x1eb184(0x1c5)][_0x1eb184(0x207)]);const {filename:_0x5b8d79,url:_0x4a1cab,width:_0x418df4,height:_0x34c789,size:_0x34cfec}=attachments[0x0],_0x53d03a=this['globalConfigService'][_0x1eb184(0x235)]([_0x1eb184(0x219)]);let _0x219261='';(!Number(_0x53d03a)||Number(_0x53d03a)===0x0)&&(_0x219261=await this[_0x1eb184(0x1c3)][_0x1eb184(0x223)]({'filename':_0x5b8d79,'url':_0x4a1cab}),console[_0x1eb184(0x24a)]('存入图片完成:\x20',_0x219261));const _0x5d9e13={'curIp':(0x0,utils_1['getClientIp'])(_0x1979ca),'userId':_0x1979ca['user']['id'],'type':balance_constant_1[_0x1eb184(0x1cf)][_0x1eb184(0x1ff)],'prompt':_0x577446,'answer':_0x219261,'model':'mj','extend':this[_0x1eb184(0x1d4)](JSON[_0x1eb184(0x231)](_0xcb45f6)),'message_id':_0x501b24,'upscaleId':_0x41e0a9,'variationId':_0x41e0a9,'action':_0x1eb184(0x205),'orderId':_0x28af53[_0x1eb184(0x249)],'isSaveImg':!Number(_0x53d03a)||Number(_0x53d03a)===0x0,'fileInfo':JSON[_0x1eb184(0x231)]({'width':_0x418df4,'height':_0x34c789,'size':_0x34cfec,'filename':_0x5b8d79,'cosUrl':_0x219261})};return await this[_0x1eb184(0x1ca)][_0x1eb184(0x211)](_0x5d9e13),_0x219261;}catch(_0x39f8a2){console[_0x1eb184(0x24a)](_0x1eb184(0x218),_0x39f8a2),this[_0x1eb184(0x24d)]--,this[_0x1eb184(0x24d)]<0x0&&(this[_0x1eb184(0x24d)]=0x0),console['log']('放大图片任务异常中断\x20队列-1:\x20',this[_0x1eb184(0x24d)]);throw new common_1[(_0x1eb184(0x1dc))](_0x39f8a2[_0x1eb184(0x255)],common_1[_0x1eb184(0x1c5)]['BAD_REQUEST']);}}async[_0x271d47(0x222)](_0x462807,_0x408fbe){const _0x5759be=_0x271d47;if(this[_0x5759be(0x24d)]>=0x3)throw new common_1[(_0x5759be(0x1dc))](_0x5759be(0x1d8),common_1['HttpStatus'][_0x5759be(0x207)]);await this['checkAuth'](_0x408fbe),await this[_0x5759be(0x22e)](_0x408fbe),this[_0x5759be(0x24d)]++,console[_0x5759be(0x24a)]('用户'+_0x408fbe['user']['id']+_0x5759be(0x261),this['queueCount']);const {message_id:_0xef20a3,orderId:_0x4eabcc}=_0x462807;try{const _0x2e40de=await this[_0x5759be(0x1eb)][_0x5759be(0x20e)]({'where':{'message_id':_0xef20a3}});if(!_0x2e40de)throw new common_1[(_0x5759be(0x1dc))](_0x5759be(0x246),common_1['HttpStatus']['BAD_REQUEST']);const {prompt:_0x155763,extend:_0x590a23}=_0x2e40de;let _0x26fd6c=null;try{_0x26fd6c=JSON['parse'](_0x590a23);}catch(_0x506b04){_0x26fd6c=[];}const {components:components=[]}=_0x26fd6c;if(!components[_0x5759be(0x21e)])throw new common_1[(_0x5759be(0x1dc))](_0x5759be(0x220),common_1[_0x5759be(0x1c5)]['BAD_REQUEST']);const _0x5ab264=components[0x1]['components'][_0x4eabcc-0x1],{custom_id:_0xfd5a54}=_0x5ab264,_0x4cd769=await this[_0x5759be(0x1eb)]['find']({'where':{'variationId':(0x0,typeorm_1['Not'])((0x0,typeorm_1[_0x5759be(0x232)])()),'prompt':(0x0,typeorm_1[_0x5759be(0x1ea)])('%'+_0x155763+'%')}}),_0x55fb55=_0x4cd769[_0x5759be(0x257)](_0x57a9cd=>_0x57a9cd[_0x5759be(0x1c9)]),_0x49fede={'message_id':_0xef20a3,'custom_id':_0xfd5a54,'prompt':_0x155763,'orderId':_0x4eabcc};await this[_0x5759be(0x200)](_0x49fede);const _0x11635a=await this['pollForVariationResult'](_0x49fede,_0x55fb55);this[_0x5759be(0x24d)]--,this[_0x5759be(0x24d)]<0x0&&(this[_0x5759be(0x24d)]=0x0),console[_0x5759be(0x24a)](_0x5759be(0x259),this[_0x5759be(0x24d)]);const {id:_0x1fdde5,content:_0x207f3f,channel_id:_0x55d162,attachments:attachments=[],timestamp:_0x484682}=_0x11635a;if(!attachments[_0x5759be(0x21e)]||!attachments[0x0][_0x5759be(0x1b7)])throw new common_1[(_0x5759be(0x1dc))](_0x5759be(0x1e8),common_1[_0x5759be(0x1c5)][_0x5759be(0x207)]);const {filename:_0x531f8b,url:_0x25b105,width:_0x32246,height:_0x188cf8,size:_0x14be81}=attachments[0x0],_0x2bb22b=this[_0x5759be(0x210)][_0x5759be(0x235)](['mjNotSaveImg']);let _0x17f905='';(!Number(_0x2bb22b)||Number(_0x2bb22b)===0x0)&&(_0x17f905=await this['uploadService'][_0x5759be(0x223)]({'filename':_0x531f8b,'url':_0x25b105}),console[_0x5759be(0x24a)]('存入图片完成:\x20',_0x17f905));const _0xac26f7={'curIp':(0x0,utils_1[_0x5759be(0x233)])(_0x408fbe),'userId':_0x408fbe[_0x5759be(0x23d)]['id'],'type':balance_constant_1['DeductionKey'][_0x5759be(0x1ff)],'prompt':_0x155763,'answer':_0x17f905,'model':'mj','group':0x1,'extend':this['removeEmoji'](JSON[_0x5759be(0x231)](_0x11635a)),'message_id':_0x1fdde5,'upscaleId':_0x1fdde5,'variationId':_0x1fdde5,'action':'enlarge','orderId':_0x49fede[_0x5759be(0x249)],'isSaveImg':!Number(_0x2bb22b)||Number(_0x2bb22b)===0x0,'fileInfo':JSON['stringify']({'width':_0x32246,'height':_0x188cf8,'size':_0x14be81,'filename':_0x531f8b,'cosUrl':_0x17f905})};return await this[_0x5759be(0x1ca)][_0x5759be(0x211)](_0xac26f7),_0x17f905;}catch(_0x1f498f){console[_0x5759be(0x24a)]('error:\x20',_0x1f498f),this[_0x5759be(0x24d)]--,this['queueCount']<0x0&&(this[_0x5759be(0x24d)]=0x0),console[_0x5759be(0x24a)](_0x5759be(0x254),this['queueCount']);throw new common_1[(_0x5759be(0x1dc))](_0x1f498f['response'],common_1['HttpStatus'][_0x5759be(0x207)]);}}async['sendSmInteractions'](_0x289b99){const _0x44f51f=_0x271d47,{message_id:_0x9d2a2b,custom_id:_0x167f7d}=_0x289b99,{application_id:_0x5a003b,guild_id:_0x4f7f6e,channel_id:_0x4ba30f,session_id:_0x48de0f,version:_0x27c832,id:_0x19ed1e,authorization:_0x303a85,mjProxy:_0xbaf1b7}=await this[_0x44f51f(0x21d)](),_0x540db8=_0xbaf1b7==0x1?_0x44f51f(0x240):_0x44f51f(0x1e4),_0x359ca7={'authorization':_0x303a85},_0x35fbf9={'type':0x3,'guild_id':_0x4f7f6e,'channel_id':_0x4ba30f,'message_flags':0x0,'message_id':_0x9d2a2b,'application_id':_0x5a003b,'session_id':_0x48de0f,'data':{'component_type':0x2,'custom_id':_0x167f7d}};try{await axios_1['default'][_0x44f51f(0x1b5)](_0x540db8,_0x35fbf9,{'headers':_0x359ca7}),console[_0x44f51f(0x24a)](_0x44f51f(0x221));}catch(_0xfc5763){console[_0x44f51f(0x24a)]('error:\x20',_0xfc5763);throw new common_1['HttpException'](_0x44f51f(0x22b),common_1[_0x44f51f(0x1c5)]['BAD_REQUEST']);}}async[_0x271d47(0x1fc)](_0x152a36,_0x113dda){const _0x3fbab6=_0x271d47,{message_id:_0x458a08,custom_id:_0xc810f3,prompt:_0x1e88e5,orderId:_0x192c1c}=_0x152a36;let _0x54c6db=null,_0x4c187a=0x0;while(!_0x54c6db&&_0x4c187a<0xa){try{const _0x4ad57a=Date[_0x3fbab6(0x250)](),_0x241dc9=await this[_0x3fbab6(0x245)]();console[_0x3fbab6(0x24a)]('第\x20'+(_0x4c187a+0x1)+_0x3fbab6(0x242)+_0x241dc9['length']);_0x241dc9&&_0x241dc9['length']&&(_0x54c6db=await this['findCurrentEnlargeImgResult'](_0x241dc9,_0x152a36,_0x113dda));const _0x5958ab=Date[_0x3fbab6(0x250)]()-_0x4ad57a,_0x52d84e=0xbb8;await this[_0x3fbab6(0x1fe)](Math[_0x3fbab6(0x1ac)](_0x52d84e-_0x5958ab,0x0)),_0x4c187a++;}catch(_0x264d2a){console[_0x3fbab6(0x1ec)](_0x3fbab6(0x239)+_0x264d2a['message']);}}return _0x54c6db;}async[_0x271d47(0x1e7)](_0x1d836f,_0x1f9766){const _0x553ce1=_0x271d47,{message_id:_0xaf4e3a,custom_id:_0xbd5e34,prompt:_0x250e74,orderId:_0xc7e11a}=_0x1d836f;console['log'](_0x553ce1(0x236));let _0x146ba6=null,_0x57f195=0x0;while(!_0x146ba6&&_0x57f195<0xa){try{console['log']('第\x20'+(_0x57f195+0x1)+_0x553ce1(0x1f5));const _0x55dc29=Date[_0x553ce1(0x250)](),_0x5217fa=await this[_0x553ce1(0x245)]();_0x5217fa&&_0x5217fa[_0x553ce1(0x21e)]&&(_0x146ba6=await this[_0x553ce1(0x1e2)](_0x5217fa,_0x1d836f,_0x1f9766));const _0x11a7d2=Date[_0x553ce1(0x250)]()-_0x55dc29,_0x2c37fa=0x1f40;await this[_0x553ce1(0x1fe)](Math['max'](_0x2c37fa-_0x11a7d2,0x0)),_0x57f195++;}catch(_0xe8abd2){console[_0x553ce1(0x1ec)](_0x553ce1(0x239)+_0xe8abd2['message']);}}if(!_0x146ba6)throw new common_1[(_0x553ce1(0x1dc))](_0x553ce1(0x1c7),common_1[_0x553ce1(0x1c5)][_0x553ce1(0x207)]);return _0x146ba6;}async[_0x271d47(0x21f)](_0x5e7fa8,_0x2baf04,_0x256786){const _0x1b6829=_0x271d47,{message_id:_0x1ddbaf,custom_id:_0x2ec27b,prompt:_0x2ee609,orderId:_0x32f5a}=_0x2baf04,_0x8b0373=_0x2ee609[_0x1b6829(0x208)](0x0,0xc);console[_0x1b6829(0x24a)](_0x1b6829(0x229),_0x8b0373);const _0x1b9912=_0x5e7fa8[_0x1b6829(0x22f)](_0x5d99ab=>{const _0x3443f0=_0x1b6829,{content:_0x11f64f}=_0x5d99ab;if(!this[_0x3443f0(0x22a)](_0x11f64f))return![];const {prompt:_0x1d4c4c,order:_0x273230}=this[_0x3443f0(0x22a)](_0x11f64f);return _0x1d4c4c['includes'](_0x8b0373)&&_0x2baf04['orderId']===_0x273230&&!_0x256786['includes'](_0x5d99ab['id']);});return _0x1b9912;}async[_0x271d47(0x1e2)](_0x3338db,_0x1eb600,_0x8331a9){const _0x5afeba=_0x271d47,{message_id:_0x22becb,custom_id:_0x213371,prompt:_0x5456b2,orderId:_0x179d42}=_0x1eb600,_0x188214=_0x5456b2[_0x5afeba(0x208)](0x0,0xc),_0x1c7d1e=_0x3338db[_0x5afeba(0x22f)](_0x4f476a=>{const _0x32ebbf=_0x5afeba,{content:_0x339ea8}=_0x4f476a,_0x562c5a=_0x339ea8[_0x32ebbf(0x1d6)](/\*\*(.+?)\*\*/),_0x4e9c55=_0x562c5a?_0x562c5a[0x1]:'';if(!_0x4e9c55)return![];return _0x4e9c55[_0x32ebbf(0x1f0)](_0x188214)&&!_0x8331a9[_0x32ebbf(0x1f0)](_0x4f476a['id']);});return _0x1c7d1e;}async[_0x271d47(0x230)](_0x3f61c2,_0x1d6909,_0x11fa3a){const _0x1813a8=_0x271d47,_0x34201c=await this[_0x1813a8(0x245)](),_0x1839fd=await this['findCurrentPromptResult'](_0x34201c,_0x11fa3a,_0x1d6909);if(_0x1839fd)return console[_0x1813a8(0x24a)]('有历史信息之间返回:\x20',_0x1839fd),_0x1839fd;const {application_id:_0x395b9c,guild_id:_0x5d3b14,channel_id:_0x47451a,session_id:_0x30841e,version:_0x1064a8,id:_0x30f0bb,authorization:_0x106adc,mjProxy:_0x24a36f}=await this[_0x1813a8(0x21d)](),_0x1e93f5={'type':0x2,'application_id':_0x395b9c,'guild_id':_0x5d3b14,'channel_id':_0x47451a,'session_id':_0x30841e,'data':{'version':_0x1064a8,'id':_0x30f0bb,'name':_0x1813a8(0x1f9),'type':0x1,'options':[{'type':0x3,'name':_0x1813a8(0x25c),'value':_0x3f61c2}],'attachments':[]}};try{const _0x277d93=_0x24a36f==0x1?_0x1813a8(0x240):_0x1813a8(0x1e4),_0x4c804b={'authorization':_0x106adc},_0x22db76=await axios_1['default'][_0x1813a8(0x1b5)](_0x277d93,_0x1e93f5,{'headers':_0x4c804b});return console[_0x1813a8(0x24a)](_0x1813a8(0x227),_0x22db76[_0x1813a8(0x20d)]),![];}catch(_0x5b278a){console[_0x1813a8(0x24a)](_0x1813a8(0x209),_0x5b278a);throw new common_1[(_0x1813a8(0x1dc))](_0x1813a8(0x1d3),common_1[_0x1813a8(0x1c5)][_0x1813a8(0x207)]);}}async[_0x271d47(0x216)](_0x2bbe0b,_0xed3af5,_0x468207){const _0x1c9dce=_0x271d47;console[_0x1c9dce(0x24a)]('开始查询绘画结果轮询');const _0x16fd10=Date[_0x1c9dce(0x250)]();try{const _0x49b525=0xd,_0x35c861=0x2ee0,_0x593182=0x1388,_0xf52d55=0x3c*0x3e8;let _0x30a970=0x0,_0x27dde4=![],_0x4981b4=null;while(!_0x4981b4&&_0x30a970<_0x49b525){console['log']('第\x20'+(_0x30a970+0x1)+'\x20次开始查询');Date[_0x1c9dce(0x250)]()-_0x16fd10>=_0xf52d55&&(_0x27dde4=!![]);await this['sleep'](_0x27dde4?_0x593182:_0x35c861);const _0x5a7501=await this[_0x1c9dce(0x245)]();_0x4981b4=await this[_0x1c9dce(0x243)](_0x5a7501,_0x468207,_0xed3af5),_0x30a970++;}if(!_0x4981b4)throw new common_1[(_0x1c9dce(0x1dc))]('绘画超时,请稍后再试!',common_1[_0x1c9dce(0x1c5)][_0x1c9dce(0x207)]);const _0x21df84=Date[_0x1c9dce(0x250)]();return console[_0x1c9dce(0x24a)](_0x1c9dce(0x253)+Math[_0x1c9dce(0x22c)]((_0x21df84-_0x16fd10)/0x3e8)+'\x20S'),_0x4981b4;}catch(_0x28fa7b){console[_0x1c9dce(0x1ec)](_0x28fa7b[_0x1c9dce(0x1c2)]);throw new common_1[(_0x1c9dce(0x1dc))](_0x1c9dce(0x1b4),common_1[_0x1c9dce(0x1c5)][_0x1c9dce(0x1b8)]);}}async[_0x271d47(0x243)](_0x141de7,_0x50e945,_0x5ae523){const _0x4ff084=_0x271d47;if(!_0x141de7||!_0x141de7[_0x4ff084(0x21e)])return;console[_0x4ff084(0x24a)](_0x4ff084(0x23c),_0x50e945);const _0x37c2f8=_0x141de7[_0x4ff084(0x22f)](_0x257ca3=>{const _0x11f490=_0x4ff084,{attachments:attachments=[],content:_0x4a7482,edited_timestamp:_0x41466b}=_0x257ca3;return _0x4a7482[_0x11f490(0x1f0)](_0x50e945)&&attachments['length']>0x0&&!_0x41466b&&!_0x5ae523[_0x11f490(0x1f0)](_0x257ca3['id']);});return _0x37c2f8||null;}async[_0x271d47(0x245)](){const _0xa219a5=_0x271d47;try{const {application_id:_0x227ae5,guild_id:_0x2dbab5,channel_id:_0x56ca77,session_id:_0x235469,version:_0x4a5ffe,id:_0x3e9a1f,authorization:_0x557870,mjProxy:_0x2ca086}=await this[_0xa219a5(0x21d)](),_0x26f60a=_0x2ca086==0x1?'http://172.247.48.137:8000/mj/list?channel_id='+_0x56ca77:_0xa219a5(0x25e)+_0x56ca77+_0xa219a5(0x20f),_0x4eff6={'authorization':_0x557870},_0x1519a1=await axios_1[_0xa219a5(0x20b)][_0xa219a5(0x1cd)](_0x26f60a,{'headers':_0x4eff6});return _0x1519a1[_0xa219a5(0x20d)];}catch(_0x2a91c0){console[_0xa219a5(0x24a)](_0xa219a5(0x1c8),_0x2a91c0);throw new common_1['HttpException'](_0xa219a5(0x1f2),common_1['HttpStatus'][_0xa219a5(0x207)]);}}async[_0x271d47(0x1fe)](_0x17d708){return new Promise(_0x4a1277=>setTimeout(_0x4a1277,_0x17d708));}[_0x271d47(0x22a)](_0x2887c3){const _0x4ad223=_0x271d47,_0x579d46=_0x2887c3[_0x4ad223(0x1d6)](/\*\*(.+?)\*\*/),_0x2f93ee=_0x2887c3[_0x4ad223(0x1d6)](/- Image #(\d+)/);if(!_0x579d46||!_0x2f93ee)return null;const _0x19ee22=_0x579d46[0x1],_0x3d6f26=parseInt(_0x2f93ee[0x1]);return{'prompt':_0x19ee22,'order':_0x3d6f26};}async[_0x271d47(0x21d)](){const _0x3918a8=_0x271d47,_0x279904=await this[_0x3918a8(0x210)][_0x3918a8(0x235)]([_0x3918a8(0x1ae),_0x3918a8(0x1b6),_0x3918a8(0x260),'mjChannelId',_0x3918a8(0x1b9),_0x3918a8(0x258),_0x3918a8(0x1e1),_0x3918a8(0x234),_0x3918a8(0x226)]),_0x5a1c47={'application_id':_0x279904[_0x3918a8(0x1b6)],'guild_id':_0x279904[_0x3918a8(0x260)],'channel_id':_0x279904[_0x3918a8(0x25a)],'session_id':_0x279904['mjSessionId'],'version':_0x279904['mjVersion'],'id':_0x279904['mjId'],'authorization':_0x279904['mjAuthorization'],'mjRateLimit':_0x279904[_0x3918a8(0x234)],'mjProxy':_0x279904[_0x3918a8(0x226)]||0x0};return _0x5a1c47;}[_0x271d47(0x1d4)](_0x566ac0){const _0x4326dc=_0x271d47,_0x3d80c0=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return _0x566ac0[_0x4326dc(0x1ef)](_0x3d80c0,'');}async[_0x271d47(0x1b3)](_0x250ed8){const _0x51da60=_0x271d47,_0x16e62f=await this['balanceEntity']['findOne']({'where':{'userId':_0x250ed8[_0x51da60(0x23d)]['id']}}),{id:_0x4688ad,balance:_0x1bfc4f}=_0x16e62f;if(!_0x1bfc4f||(_0x16e62f===null||_0x16e62f===void 0x0?void 0x0:_0x16e62f[_0x51da60(0x1c0)])<0x1)throw new common_1[(_0x51da60(0x1dc))]('您当前暂无MJ绘画余额!!!',common_1[_0x51da60(0x1c5)][_0x51da60(0x207)]);}async['checkFree'](_0x313e74){const _0x1756ba=_0x271d47,{id:_0x18030e,role:_0x2cba9c}=_0x313e74[_0x1756ba(0x23d)];!this[_0x1756ba(0x23a)][_0x18030e]?this['freeQueueUsers'][_0x18030e]=0x1:this[_0x1756ba(0x23a)][_0x18030e]=this[_0x1756ba(0x23a)][_0x18030e]+0x1,console[_0x1756ba(0x24a)]('当前用户'+_0x18030e+_0x1756ba(0x252),this[_0x1756ba(0x23a)][_0x18030e]);}async[_0x271d47(0x22e)](_0x4ee705){const _0x37b21d=_0x271d47,{id:_0x24353f,role:_0x11d5a6}=_0x4ee705[_0x37b21d(0x23d)];if([_0x37b21d(0x241),_0x37b21d(0x25f)]['includes'](_0x11d5a6))return!![];const {mjRateLimit:_0x235572}=await this[_0x37b21d(0x21d)]();if(this[_0x37b21d(0x1b1)][_0x24353f]){const _0x3e9e62=this[_0x37b21d(0x1b1)][_0x24353f];if(_0x3e9e62>Date[_0x37b21d(0x250)]()){console[_0x37b21d(0x24a)](_0x37b21d(0x215)+_0x24353f+_0x37b21d(0x1ed));throw new common_1[(_0x37b21d(0x1dc))](_0x37b21d(0x23e)+_0x235572+_0x37b21d(0x1f8),common_1[_0x37b21d(0x1c5)][_0x37b21d(0x207)]);}else this['rateLimits'][_0x24353f]=Date[_0x37b21d(0x250)]()+Number(_0x235572)*0x3e8;}else{const _0x5199b4=Date[_0x37b21d(0x250)]();this[_0x37b21d(0x1b1)][_0x24353f]=_0x5199b4+0x3e8*Number(_0x235572);}}async[_0x271d47(0x225)](_0x1404e8){const _0x462b39=_0x271d47;await this[_0x462b39(0x248)][_0x462b39(0x1d7)]()[_0x462b39(0x1f4)](balance_entity_1['BalanceEntity'])[_0x462b39(0x1dd)]({'balance':()=>_0x462b39(0x1e5)})[_0x462b39(0x1d0)](_0x462b39(0x1c6),{'userId':_0x1404e8[_0x462b39(0x23d)]['id']})[_0x462b39(0x24c)]();}async[_0x271d47(0x202)](){return 0x1;}};function _0xcc22(){const _0x2a4675=['error','\x20请求过于频繁!','parse','replace','includes','147cNOgKQ','查询绘制结果失败...','发送放大指令成功','update','\x20次开始查询[变换图片]','当前图片没有绘画信息、无法放大!','@nestjs/common','秒请求一次、请合理使用!','imagine','6213609OeRCsV','758891yptVay','pollForUpscaleResult','__metadata','sleep','PAINT_TYPE','sendSmInteractions','badwordsService','test','306jPTmdb','@nestjs/typeorm','enlarge','绘画任务开始','BAD_REQUEST','substring','axios:\x20','function','default','__esModule','data','findOne','/messages?limit=50','globalConfigService','saveChatLog','../chatLog/chatLog.entity','BadwordsService','message_id','当前用户\x20','pollForResult','GlobalConfigService','error:\x20','mjNotSaveImg','ChatLogService','90052dAQVbr','fanyiService','getMjDefaultParams','length','findCurrentEnlargeImgResult','当前图片没有绘画信息、无法变体!','绘图指令完成','variationSingleImg','uploadFileFromUrl','design:paramtypes','deductBalance','mjProxy','发送绘画指令结果:\x20','../chatLog/chatLog.service','本次放大图片的id:\x20','extractContent','放大单张图片请求失败...','floor','baiduFanyiSecret','checkRateLimit','find','sendDrawInteractions','stringify','IsNull','getClientIp','mjRateLimit','getConfigs','开始轮询单张变换图片结果','convertToEnglish','17039YwaDOi','查询期间出现错误:','freeQueueUsers','push','本次比对的随机ID:\x20','user','由于速率限制、当前普通用户限制为','mjservice','http://172.247.48.137:8000/mj/draw','admin','\x20次开始查询\x20=>\x20当前查询结果:','findCurrentPromptResult','InjectRepository','queryMessageList','历史记录中不存在当前图片、请确认您需要变换的图片是否存在','5110oAaPUv','balanceEntity','orderId','log','\x20队列+1:\x20','execute','queueCount','20705Xklpkz','放大custom_id:\x20','now','当前图片已经放大过了、请勿重复放大!','使用的次数:','本次绘图耗时:\x20','变化图片任务异常中断\x20队列-1:\x20','response','typeorm','map','mjVersion','变换图片任务结束\x20队列-1:\x20','mjChannelId','__param','prompt','createRandomUid','https://discord.com/api/v9/channels/','super','mjGuildId','开始请求变换图片\x20队列+1:\x20','max','ChatLogEntity','mjId','1451932NoYRML','object','rateLimits','components','checkAuth','网络连接失败,请稍后再试!','post','mjApplicationId','url','INTERNAL_SERVER_ERROR','mjSessionId','放大当前图片失败','MjService','8xcSzMg','checkBadWords','drawWorking','axios','balance','randomId:\x20','message','uploadService','decorate','HttpStatus','userId\x20=\x20:userId','变换当前图片超时!','axios\x20get:\x20','variationId','chatLogService','Repository','绘制图片任务结束\x20队列-1:\x20','get','开始请求用户','DeductionKey','where','__decorate','../globalConfig/globalConfig.service','绘画请求失败、当前使用人数过多、请稍后试试吧、排队中...','removeEmoji','draw','match','createQueryBuilder','当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...','upscaleSingleImg','baiduFanyiAppId','../userBalance/balance.entity','HttpException','set','1343782ByYEPw','metadata','当前提示词已经在任务队列中了、请勿重复提交。。。','mjAuthorization','findCurrentVariationImgResult','defineProperty','https://discord.com/api/v9/interactions','balance\x20-\x201','BalanceEntity','pollForVariationResult','变换当前图片失败','filter','Like','chatLogEntity'];_0xcc22=function(){return _0x2a4675;};return _0xcc22();}MjService=__decorate([(0x0,common_1['Injectable'])(),__param(0x0,(0x0,typeorm_2[_0x271d47(0x244)])(chatLog_entity_1[_0x271d47(0x1ad)])),__param(0x1,(0x0,typeorm_2[_0x271d47(0x244)])(balance_entity_1[_0x271d47(0x1e6)])),__metadata(_0x271d47(0x224),[typeorm_1[_0x271d47(0x1cb)],typeorm_1[_0x271d47(0x1cb)],upload_service_1['UploadService'],chatLog_service_1[_0x271d47(0x21a)],globalConfig_service_1[_0x271d47(0x217)],fanyi_service_1['FanyiService'],badwords_service_1[_0x271d47(0x213)]])],MjService),exports[_0x271d47(0x1bb)]=MjService; |