YiAi/YiAiQuickDeploy/dist/modules/mj/mj.service.js
2024-02-05 23:18:50 +08:00

1 line
28 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';const _0xe14858=_0x2c86;(function(_0x570152,_0x59a2a5){const _0x441408=_0x2c86,_0x2038af=_0x570152();while(!![]){try{const _0x50a813=-parseInt(_0x441408(0xec))/0x1*(parseInt(_0x441408(0xd5))/0x2)+parseInt(_0x441408(0x147))/0x3*(-parseInt(_0x441408(0x13e))/0x4)+parseInt(_0x441408(0x11a))/0x5*(-parseInt(_0x441408(0xa8))/0x6)+parseInt(_0x441408(0x10f))/0x7+-parseInt(_0x441408(0x105))/0x8*(parseInt(_0x441408(0xf2))/0x9)+parseInt(_0x441408(0x144))/0xa+parseInt(_0x441408(0xf3))/0xb;if(_0x50a813===_0x59a2a5)break;else _0x2038af['push'](_0x2038af['shift']());}catch(_0x3a5c3f){_0x2038af['push'](_0x2038af['shift']());}}}(_0x1a0b,0xbe025));var __decorate=this&&this[_0xe14858(0xbd)]||function(_0x271312,_0x19d66b,_0x3bd742,_0x5046bb){const _0x29b1e5=_0xe14858;var _0x545285=arguments[_0x29b1e5(0xae)],_0x33f797=_0x545285<0x3?_0x19d66b:_0x5046bb===null?_0x5046bb=Object['getOwnPropertyDescriptor'](_0x19d66b,_0x3bd742):_0x5046bb,_0x2df7a1;if(typeof Reflect===_0x29b1e5(0xa3)&&typeof Reflect[_0x29b1e5(0x102)]===_0x29b1e5(0x11e))_0x33f797=Reflect[_0x29b1e5(0x102)](_0x271312,_0x19d66b,_0x3bd742,_0x5046bb);else{for(var _0x4b5a1d=_0x271312['length']-0x1;_0x4b5a1d>=0x0;_0x4b5a1d--)if(_0x2df7a1=_0x271312[_0x4b5a1d])_0x33f797=(_0x545285<0x3?_0x2df7a1(_0x33f797):_0x545285>0x3?_0x2df7a1(_0x19d66b,_0x3bd742,_0x33f797):_0x2df7a1(_0x19d66b,_0x3bd742))||_0x33f797;}return _0x545285>0x3&&_0x33f797&&Object[_0x29b1e5(0x11b)](_0x19d66b,_0x3bd742,_0x33f797),_0x33f797;},__metadata=this&&this[_0xe14858(0x9a)]||function(_0x587790,_0x26b985){const _0x3c7e5c=_0xe14858;if(typeof Reflect===_0x3c7e5c(0xa3)&&typeof Reflect[_0x3c7e5c(0x129)]===_0x3c7e5c(0x11e))return Reflect[_0x3c7e5c(0x129)](_0x587790,_0x26b985);},__param=this&&this[_0xe14858(0xe8)]||function(_0x11de59,_0x1316cf){return function(_0x36e515,_0x41f7e7){_0x1316cf(_0x36e515,_0x41f7e7,_0x11de59);};};Object[_0xe14858(0x11b)](exports,_0xe14858(0x139),{'value':!![]}),exports[_0xe14858(0x135)]=void 0x0;const globalConfig_service_1=require('../globalConfig/globalConfig.service'),upload_service_1=require('../upload/upload.service'),common_1=require('@nestjs/common'),axios_1=require(_0xe14858(0xf4)),chatLog_service_1=require('../chatLog/chatLog.service'),balance_constant_1=require(_0xe14858(0x13a)),utils_1=require('../../common/utils'),chatLog_entity_1=require('../chatLog/chatLog.entity'),typeorm_1=require(_0xe14858(0x130)),typeorm_2=require(_0xe14858(0xc9)),balance_entity_1=require('../userBalance/balance.entity'),fanyi_service_1=require('../fanyi/fanyi.service'),badwords_service_1=require(_0xe14858(0xc4));let MjService=class MjService{constructor(_0x47ef04,_0x300634,_0x533ff0,_0x239052,_0x532b3a,_0x25d599,_0x2ea850){const _0x4da391=_0xe14858;this[_0x4da391(0x114)]=_0x47ef04,this[_0x4da391(0x143)]=_0x300634,this[_0x4da391(0xc3)]=_0x533ff0,this['chatLogService']=_0x239052,this[_0x4da391(0xf1)]=_0x532b3a,this[_0x4da391(0xf7)]=_0x25d599,this[_0x4da391(0x9b)]=_0x2ea850,this[_0x4da391(0xb7)]={},this['drawWorking']=[],this[_0x4da391(0xab)]=[],this[_0x4da391(0xa5)]=0x0,this['freeQueueUsers']={};}async[_0xe14858(0xd1)](_0xfc6655){const _0x1b6a66=_0xe14858,{jobId:_0x4128f1,prompt:_0x1dc6d7,startTime:_0x30c522,userId:_0x5de13b}=_0xfc6655;return console[_0x1b6a66(0xb0)](_0x1b6a66(0x110),'mjservice'),await new Promise(_0x5436f3=>setTimeout(_0x5436f3,0x1388)),{'a':0x1,'b':0x2};}async[_0xe14858(0x122)](_0x5697c3,_0x3d244b){const _0x25daa2=_0xe14858;await this[_0x25daa2(0x103)](_0x3d244b),await this[_0x25daa2(0x9b)]['checkBadWords'](_0x5697c3[_0x25daa2(0x136)],_0x3d244b[_0x25daa2(0x120)]['id']);const _0x4a47c0=_0x5697c3[_0x25daa2(0x136)];let _0x1cbf84=_0x5697c3[_0x25daa2(0x136)];const {baiduFanyiAppId:_0x3f6d00,baiduFanyiSecret:_0x4d5a2e}=await this[_0x25daa2(0xf1)][_0x25daa2(0xef)]([_0x25daa2(0xf8),'baiduFanyiSecret']);_0x3f6d00&&_0x4d5a2e&&(_0x1cbf84=await this[_0x25daa2(0xf7)][_0x25daa2(0xbc)](_0x4a47c0));const _0x37638b='['+(0x0,utils_1[_0x25daa2(0xa7)])()+']',_0x2de7f6=_0x37638b+'\x20'+_0x1cbf84;console[_0x25daa2(0xb0)](_0x25daa2(0x137),_0x37638b),console[_0x25daa2(0xb0)](_0x25daa2(0xa1),_0x2de7f6);const _0x58b551=this['drawWorking']['find'](_0x279806=>_0x279806['includes'](_0x5697c3[_0x25daa2(0x136)]));if(_0x58b551)throw new common_1[(_0x25daa2(0xb4))]('当前提示词已经在任务队列中了、请勿重复提交。。。',common_1[_0x25daa2(0x12f)][_0x25daa2(0x134)]);if(this[_0x25daa2(0xa5)]>=0x3)throw new common_1[(_0x25daa2(0xb4))](_0x25daa2(0xc7),common_1[_0x25daa2(0x12f)]['BAD_REQUEST']);await this[_0x25daa2(0xca)](_0x3d244b),this[_0x25daa2(0xa5)]++,console[_0x25daa2(0xb0)](_0x25daa2(0x128)+_0x3d244b[_0x25daa2(0x120)]['id']+_0x25daa2(0xa9),this[_0x25daa2(0xa5)]);try{const _0x4ef084=await this['chatLogEntity'][_0x25daa2(0xad)]({'where':{'prompt':(0x0,typeorm_1['Like'])('%'+_0x2de7f6+'%')}}),_0xed9568=_0x4ef084[_0x25daa2(0x107)](_0x32b44a=>_0x32b44a[_0x25daa2(0xa6)]);this[_0x25daa2(0xb2)][_0x25daa2(0xb3)](_0x2de7f6);let _0x842615;const _0x3db080=await this[_0x25daa2(0x142)](_0x2de7f6,_0xed9568,_0x37638b);_0x3db080?(console[_0x25daa2(0xb0)](_0x25daa2(0xa4)),_0x842615=_0x3db080):_0x842615=await this[_0x25daa2(0xee)](_0x2de7f6,_0xed9568,_0x37638b);this[_0x25daa2(0xa5)]--,this[_0x25daa2(0xa5)]<0x0&&(this['queueCount']=0x0),console['log'](_0x25daa2(0xea),this[_0x25daa2(0xa5)]);const {id:_0x5462db,content:_0x48a163,channel_id:_0x5cb887,attachments:attachments=[],timestamp:_0x3511e2}=_0x842615;if(!attachments[_0x25daa2(0xae)]||!attachments[0x0][_0x25daa2(0x109)])throw new common_1[(_0x25daa2(0xb4))](_0x25daa2(0x10b),common_1[_0x25daa2(0x12f)][_0x25daa2(0x134)]);const {filename:_0x241752,url:_0x3861e0,width:_0x4e7e85,height:_0x4b7c65,size:_0x4054fe}=attachments[0x0];console['log'](_0x25daa2(0xfc),_0x3861e0);const _0x32e492=this[_0x25daa2(0xf1)][_0x25daa2(0xef)](['mjNotSaveImg']);let _0x5f45c9='';(!Number(_0x32e492)||Number(_0x32e492)===0x0)&&(_0x5f45c9=await this[_0x25daa2(0xc3)][_0x25daa2(0xbf)]({'filename':_0x241752,'url':_0x3861e0}),console[_0x25daa2(0xb0)](_0x25daa2(0x97),_0x5f45c9));const _0x5c15cd={'curIp':(0x0,utils_1[_0x25daa2(0x13b)])(_0x3d244b),'userId':_0x3d244b['user']['id'],'type':balance_constant_1[_0x25daa2(0x125)][_0x25daa2(0xd2)],'prompt':_0x2de7f6,'answer':_0x5f45c9,'model':'mj','extend':this[_0x25daa2(0x133)](JSON[_0x25daa2(0xf5)](_0x842615)),'message_id':_0x5462db,'variationId':_0x5462db,'upscaleId':_0x5462db,'group':0x1,'isSaveImg':!Number(_0x32e492)||Number(_0x32e492)===0x0,'fileInfo':JSON['stringify']({'width':_0x4e7e85,'height':_0x4b7c65,'size':_0x4054fe,'filename':_0x241752,'cosUrl':_0x5f45c9})};return await this[_0x25daa2(0x10c)][_0x25daa2(0xcf)](_0x5c15cd),await this['deductBalance'](_0x3d244b),this[_0x25daa2(0xb2)]=this[_0x25daa2(0xb2)]['filter'](_0x2dc428=>_0x2dc428!==_0x5697c3[_0x25daa2(0x136)]),_0x5f45c9;}catch(_0x38e033){this[_0x25daa2(0xa5)]--,this['queueCount']<0x0&&(this['queueCount']=0x0),console[_0x25daa2(0xb0)](_0x25daa2(0xda),this[_0x25daa2(0xa5)]),this[_0x25daa2(0xb2)]=this[_0x25daa2(0xb2)][_0x25daa2(0xe6)](_0x3f3e0d=>_0x3f3e0d!==_0x5697c3[_0x25daa2(0x136)]);throw new common_1[(_0x25daa2(0xb4))](_0x38e033['response'],common_1['HttpStatus'][_0x25daa2(0x134)]);}}async['upscaleSingleImg'](_0x1972b1,_0x530dbd){const _0x2da9b9=_0xe14858;if(this['queueCount']>=0x3)throw new common_1[(_0x2da9b9(0xb4))]('当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...',common_1[_0x2da9b9(0x12f)]['BAD_REQUEST']);this[_0x2da9b9(0xa5)]++,console['log']('用户'+_0x530dbd[_0x2da9b9(0x120)]['id']+_0x2da9b9(0xd3),this[_0x2da9b9(0xa5)]);const {message_id:_0x358731,orderId:_0xad2d56}=_0x1972b1;try{const _0x4c209c=await this[_0x2da9b9(0x114)][_0x2da9b9(0x113)]({'where':{'message_id':_0x358731}});if(!_0x4c209c)throw new common_1[(_0x2da9b9(0xb4))](_0x2da9b9(0xb1),common_1[_0x2da9b9(0x12f)][_0x2da9b9(0x134)]);const _0x1c70e9=await this[_0x2da9b9(0x114)]['findOne']({'where':{'upscaleId':_0x358731,'action':'enlarge','orderId':_0xad2d56}});if(_0x1c70e9)throw new common_1[(_0x2da9b9(0xb4))]('当前图片已经放大过了、请勿重复放大!',common_1[_0x2da9b9(0x12f)][_0x2da9b9(0x134)]);const {prompt:_0x206169,extend:_0x47508f}=_0x4c209c;let _0x6f6c92=null;try{_0x6f6c92=JSON['parse'](_0x47508f);}catch(_0x22e363){_0x6f6c92=[];}const {components:components=[]}=_0x6f6c92;if(!components['length'])throw new common_1[(_0x2da9b9(0xb4))](_0x2da9b9(0xf0),common_1[_0x2da9b9(0x12f)][_0x2da9b9(0x134)]);const _0x385b68=components[0x0][_0x2da9b9(0xfa)][_0xad2d56-0x1],{custom_id:_0x5f39c3}=_0x385b68;console[_0x2da9b9(0xb0)]('放大custom_id:\x20',_0x5f39c3);const _0x3feeca={'message_id':_0x358731,'custom_id':_0x5f39c3,'prompt':_0x206169,'orderId':_0xad2d56};await this['sendSmInteractions'](_0x3feeca),console[_0x2da9b9(0xb0)](_0x2da9b9(0x117));const _0x407d4a=await this[_0x2da9b9(0x114)][_0x2da9b9(0xad)]({'where':{'prompt':(0x0,typeorm_1['Like'])('%'+_0x206169+'%')}}),_0x2da5af=_0x407d4a[_0x2da9b9(0x107)](_0x246396=>_0x246396['message_id']);console['log']('历史这些id已经被获取过了\x20不能拿了:\x20',_0x2da5af);const _0x3f6ac9=await this[_0x2da9b9(0xe5)](_0x3feeca,_0x2da5af);this[_0x2da9b9(0xa5)]--,this[_0x2da9b9(0xa5)]<0x0&&(this[_0x2da9b9(0xa5)]=0x0),console['log']('放大图片任务结束\x20队列-1:\x20',this[_0x2da9b9(0xa5)]);const {id:_0x5df59a,content:_0x1f9e61,channel_id:_0x583945,attachments:attachments=[],timestamp:_0x749707}=_0x3f6ac9;if(!attachments[_0x2da9b9(0xae)]||!attachments[0x0][_0x2da9b9(0x109)])throw new common_1[(_0x2da9b9(0xb4))](_0x2da9b9(0x11c),common_1['HttpStatus'][_0x2da9b9(0x134)]);const {filename:_0x29b751,url:_0x138e18,width:_0x314ff3,height:_0x2867aa,size:_0x5891d7}=attachments[0x0],_0x3c8680=this[_0x2da9b9(0xf1)][_0x2da9b9(0xef)]([_0x2da9b9(0xd7)]);let _0x3c9e9a='';(!Number(_0x3c8680)||Number(_0x3c8680)===0x0)&&(_0x3c9e9a=await this[_0x2da9b9(0xc3)][_0x2da9b9(0xbf)]({'filename':_0x29b751,'url':_0x138e18}),console['log']('存入图片完成:\x20',_0x3c9e9a));const _0x5b4444={'curIp':(0x0,utils_1[_0x2da9b9(0x13b)])(_0x530dbd),'userId':_0x530dbd['user']['id'],'type':balance_constant_1[_0x2da9b9(0x125)]['PAINT_TYPE'],'prompt':_0x206169,'answer':_0x3c9e9a,'model':'mj','extend':this[_0x2da9b9(0x133)](JSON[_0x2da9b9(0xf5)](_0x3f6ac9)),'message_id':_0x358731,'upscaleId':_0x5df59a,'variationId':_0x5df59a,'action':_0x2da9b9(0xba),'orderId':_0x3feeca[_0x2da9b9(0xb5)],'isSaveImg':!Number(_0x3c8680)||Number(_0x3c8680)===0x0,'fileInfo':JSON[_0x2da9b9(0xf5)]({'width':_0x314ff3,'height':_0x2867aa,'size':_0x5891d7,'filename':_0x29b751,'cosUrl':_0x3c9e9a})};return await this['chatLogService'][_0x2da9b9(0xcf)](_0x5b4444),_0x3c9e9a;}catch(_0x50a286){console['log'](_0x2da9b9(0xc0),_0x50a286),this[_0x2da9b9(0xa5)]--,this['queueCount']<0x0&&(this[_0x2da9b9(0xa5)]=0x0),console[_0x2da9b9(0xb0)](_0x2da9b9(0x119),this[_0x2da9b9(0xa5)]);throw new common_1['HttpException'](_0x50a286['response'],common_1['HttpStatus'][_0x2da9b9(0x134)]);}}async[_0xe14858(0xfb)](_0x47d5fe,_0x8688e5){const _0x293c08=_0xe14858;if(this[_0x293c08(0xa5)]>=0x3)throw new common_1[(_0x293c08(0xb4))](_0x293c08(0xc7),common_1[_0x293c08(0x12f)][_0x293c08(0x134)]);await this[_0x293c08(0x103)](_0x8688e5),await this[_0x293c08(0xca)](_0x8688e5),this[_0x293c08(0xa5)]++,console[_0x293c08(0xb0)]('用户'+_0x8688e5[_0x293c08(0x120)]['id']+_0x293c08(0x13d),this[_0x293c08(0xa5)]);const {message_id:_0x324beb,orderId:_0x2c0845}=_0x47d5fe;try{const _0x2c5a88=await this[_0x293c08(0x114)][_0x293c08(0x113)]({'where':{'message_id':_0x324beb}});if(!_0x2c5a88)throw new common_1[(_0x293c08(0xb4))](_0x293c08(0x12b),common_1['HttpStatus'][_0x293c08(0x134)]);const {prompt:_0x54d056,extend:_0x5427de}=_0x2c5a88;let _0x139217=null;try{_0x139217=JSON[_0x293c08(0xb6)](_0x5427de);}catch(_0x3cf0c7){_0x139217=[];}const {components:components=[]}=_0x139217;if(!components['length'])throw new common_1[(_0x293c08(0xb4))](_0x293c08(0x10d),common_1[_0x293c08(0x12f)][_0x293c08(0x134)]);const _0x559ec1=components[0x1]['components'][_0x2c0845-0x1],{custom_id:_0x235bf5}=_0x559ec1,_0x229d3a=await this[_0x293c08(0x114)][_0x293c08(0xad)]({'where':{'variationId':(0x0,typeorm_1[_0x293c08(0x96)])((0x0,typeorm_1[_0x293c08(0xe9)])()),'prompt':(0x0,typeorm_1['Like'])('%'+_0x54d056+'%')}}),_0x48c506=_0x229d3a[_0x293c08(0x107)](_0x4e0251=>_0x4e0251[_0x293c08(0xfd)]),_0x23e086={'message_id':_0x324beb,'custom_id':_0x235bf5,'prompt':_0x54d056,'orderId':_0x2c0845};await this[_0x293c08(0xcc)](_0x23e086);const _0x34d37f=await this[_0x293c08(0x140)](_0x23e086,_0x48c506);this[_0x293c08(0xa5)]--,this[_0x293c08(0xa5)]<0x0&&(this[_0x293c08(0xa5)]=0x0),console[_0x293c08(0xb0)](_0x293c08(0x12a),this[_0x293c08(0xa5)]);const {id:_0x40fc4e,content:_0x45a345,channel_id:_0x5ea6f4,attachments:attachments=[],timestamp:_0x2c02c2}=_0x34d37f;if(!attachments[_0x293c08(0xae)]||!attachments[0x0]['url'])throw new common_1[(_0x293c08(0xb4))](_0x293c08(0xb9),common_1[_0x293c08(0x12f)][_0x293c08(0x134)]);const {filename:_0x23c233,url:_0x28c5c7,width:_0x1341ca,height:_0x4f71d0,size:_0x532c93}=attachments[0x0],_0x303c5a=this[_0x293c08(0xf1)][_0x293c08(0xef)]([_0x293c08(0xd7)]);let _0xb097f2='';(!Number(_0x303c5a)||Number(_0x303c5a)===0x0)&&(_0xb097f2=await this[_0x293c08(0xc3)][_0x293c08(0xbf)]({'filename':_0x23c233,'url':_0x28c5c7}),console[_0x293c08(0xb0)](_0x293c08(0x97),_0xb097f2));const _0x11ec99={'curIp':(0x0,utils_1[_0x293c08(0x13b)])(_0x8688e5),'userId':_0x8688e5[_0x293c08(0x120)]['id'],'type':balance_constant_1[_0x293c08(0x125)][_0x293c08(0xd2)],'prompt':_0x54d056,'answer':_0xb097f2,'model':'mj','group':0x1,'extend':this[_0x293c08(0x133)](JSON[_0x293c08(0xf5)](_0x34d37f)),'message_id':_0x40fc4e,'upscaleId':_0x40fc4e,'variationId':_0x40fc4e,'action':'enlarge','orderId':_0x23e086[_0x293c08(0xb5)],'isSaveImg':!Number(_0x303c5a)||Number(_0x303c5a)===0x0,'fileInfo':JSON['stringify']({'width':_0x1341ca,'height':_0x4f71d0,'size':_0x532c93,'filename':_0x23c233,'cosUrl':_0xb097f2})};return await this[_0x293c08(0x10c)]['saveChatLog'](_0x11ec99),_0xb097f2;}catch(_0x1d0e90){console[_0x293c08(0xb0)](_0x293c08(0xc0),_0x1d0e90),this[_0x293c08(0xa5)]--,this['queueCount']<0x0&&(this['queueCount']=0x0),console[_0x293c08(0xb0)]('变化图片任务异常中断\x20队列-1:\x20',this[_0x293c08(0xa5)]);throw new common_1['HttpException'](_0x1d0e90[_0x293c08(0xc2)],common_1[_0x293c08(0x12f)][_0x293c08(0x134)]);}}async[_0xe14858(0xcc)](_0xefdf68){const _0x348399=_0xe14858,{message_id:_0x38c92c,custom_id:_0x1aaf2b}=_0xefdf68,{application_id:_0x2a0144,guild_id:_0x374f8a,channel_id:_0x15bb3f,session_id:_0xc9e38,version:_0x22b3bb,id:_0xc49532,authorization:_0x46e328,mjProxy:_0x252abf}=await this[_0x348399(0xdb)](),_0x7fb92a=_0x252abf==0x1?_0x348399(0x98):_0x348399(0xdf),_0x479cd9={'authorization':_0x46e328},_0xd4e2a5={'type':0x3,'guild_id':_0x374f8a,'channel_id':_0x15bb3f,'message_flags':0x0,'message_id':_0x38c92c,'application_id':_0x2a0144,'session_id':_0xc9e38,'data':{'component_type':0x2,'custom_id':_0x1aaf2b}};try{await axios_1[_0x348399(0x123)][_0x348399(0x10e)](_0x7fb92a,_0xd4e2a5,{'headers':_0x479cd9}),console['log'](_0x348399(0xbe));}catch(_0x5050ca){console[_0x348399(0xb0)]('error:\x20',_0x5050ca);throw new common_1['HttpException'](_0x348399(0x11f),common_1[_0x348399(0x12f)]['BAD_REQUEST']);}}async[_0xe14858(0xe5)](_0x310401,_0x5a571b){const _0x6828c8=_0xe14858,{message_id:_0x2d6db6,custom_id:_0x11c6bd,prompt:_0x12209c,orderId:_0xc6e9}=_0x310401;let _0x188ecc=null,_0x2f8f49=0x0;while(!_0x188ecc&&_0x2f8f49<0xa){try{const _0x4dfde8=Date['now'](),_0x27d18=await this[_0x6828c8(0xdd)]();console[_0x6828c8(0xb0)]('第\x20'+(_0x2f8f49+0x1)+_0x6828c8(0xd4)+_0x27d18[_0x6828c8(0xae)]);_0x27d18&&_0x27d18['length']&&(_0x188ecc=await this[_0x6828c8(0x10a)](_0x27d18,_0x310401,_0x5a571b));const _0x5c9b73=Date[_0x6828c8(0xac)]()-_0x4dfde8,_0x4fb91d=0xbb8;await this[_0x6828c8(0x118)](Math[_0x6828c8(0xde)](_0x4fb91d-_0x5c9b73,0x0)),_0x2f8f49++;}catch(_0x1065a8){console[_0x6828c8(0xdc)](_0x6828c8(0x104)+_0x1065a8[_0x6828c8(0xa2)]);}}return _0x188ecc;}async['pollForVariationResult'](_0x153d14,_0x145a1f){const _0x2e4374=_0xe14858,{message_id:_0x448c9d,custom_id:_0x5eff07,prompt:_0xe3646d,orderId:_0x4eb34d}=_0x153d14;console[_0x2e4374(0xb0)](_0x2e4374(0x12d));let _0x378e37=null,_0x178847=0x0;while(!_0x378e37&&_0x178847<0xa){try{console[_0x2e4374(0xb0)]('第\x20'+(_0x178847+0x1)+_0x2e4374(0x9f));const _0x55bec5=Date[_0x2e4374(0xac)](),_0x2e0be4=await this[_0x2e4374(0xdd)]();_0x2e0be4&&_0x2e0be4[_0x2e4374(0xae)]&&(_0x378e37=await this['findCurrentVariationImgResult'](_0x2e0be4,_0x153d14,_0x145a1f));const _0x5ab9d4=Date[_0x2e4374(0xac)]()-_0x55bec5,_0x6b4d24=0x1f40;await this[_0x2e4374(0x118)](Math['max'](_0x6b4d24-_0x5ab9d4,0x0)),_0x178847++;}catch(_0xc841e){console[_0x2e4374(0xdc)](_0x2e4374(0x104)+_0xc841e['message']);}}if(!_0x378e37)throw new common_1[(_0x2e4374(0xb4))](_0x2e4374(0xeb),common_1[_0x2e4374(0x12f)][_0x2e4374(0x134)]);return _0x378e37;}async[_0xe14858(0x10a)](_0x419404,_0xe57258,_0x449cfd){const _0x30c9a4=_0xe14858,{message_id:_0xac91ed,custom_id:_0x2f659d,prompt:_0x304367,orderId:_0xb76104}=_0xe57258,_0x515f5f=_0x304367['substring'](0x0,0xc);console['log'](_0x30c9a4(0x11d),_0x515f5f);const _0x2117bc=_0x419404['find'](_0x17bace=>{const _0x3e4b24=_0x30c9a4,{content:_0x38f38a}=_0x17bace;if(!this[_0x3e4b24(0xe0)](_0x38f38a))return![];const {prompt:_0x4d9f75,order:_0x4e9e62}=this['extractContent'](_0x38f38a);return _0x4d9f75[_0x3e4b24(0xe7)](_0x515f5f)&&_0xe57258['orderId']===_0x4e9e62&&!_0x449cfd[_0x3e4b24(0xe7)](_0x17bace['id']);});return _0x2117bc;}async['findCurrentVariationImgResult'](_0x11fe08,_0x1022ca,_0x581dc3){const _0x278055=_0xe14858,{message_id:_0x30fda5,custom_id:_0x5ea8d0,prompt:_0x24eb7a,orderId:_0x3bf345}=_0x1022ca,_0x3c229c=_0x24eb7a['substring'](0x0,0xc),_0x298375=_0x11fe08[_0x278055(0xad)](_0x4baf9c=>{const _0x2586d1=_0x278055,{content:_0x5708bc}=_0x4baf9c,_0x1c9610=_0x5708bc['match'](/\*\*(.+?)\*\*/),_0x50fa92=_0x1c9610?_0x1c9610[0x1]:'';if(!_0x50fa92)return![];return _0x50fa92['includes'](_0x3c229c)&&!_0x581dc3[_0x2586d1(0xe7)](_0x4baf9c['id']);});return _0x298375;}async[_0xe14858(0x142)](_0x2f6f3f,_0x55fd2c,_0x48a83f){const _0x3e3b95=_0xe14858,_0x5a4a2c=await this['queryMessageList'](),_0x1016dd=await this['findCurrentPromptResult'](_0x5a4a2c,_0x48a83f,_0x55fd2c);if(_0x1016dd)return console[_0x3e3b95(0xb0)]('有历史信息之间返回:\x20',_0x1016dd),_0x1016dd;const {application_id:_0x17a13e,guild_id:_0x540a52,channel_id:_0x4f2fee,session_id:_0x42b66c,version:_0x20a25e,id:_0x17fa5a,authorization:_0x4fdc38,mjProxy:_0x14c515}=await this[_0x3e3b95(0xdb)](),_0x2c3851={'type':0x2,'application_id':_0x17a13e,'guild_id':_0x540a52,'channel_id':_0x4f2fee,'session_id':_0x42b66c,'data':{'version':_0x20a25e,'id':_0x17fa5a,'name':_0x3e3b95(0x138),'type':0x1,'options':[{'type':0x3,'name':_0x3e3b95(0x136),'value':_0x2f6f3f}],'attachments':[]}};try{const _0x17eb86=_0x14c515==0x1?_0x3e3b95(0x98):_0x3e3b95(0xdf),_0x48436d={'authorization':_0x4fdc38},_0x340017=await axios_1[_0x3e3b95(0x123)][_0x3e3b95(0x10e)](_0x17eb86,_0x2c3851,{'headers':_0x48436d});return console['log']('发送绘画指令结果:\x20',_0x340017[_0x3e3b95(0xcb)]),![];}catch(_0x3d6618){console[_0x3e3b95(0xb0)](_0x3e3b95(0x12c),_0x3d6618);throw new common_1[(_0x3e3b95(0xb4))](_0x3e3b95(0x9d),common_1[_0x3e3b95(0x12f)][_0x3e3b95(0x134)]);}}async[_0xe14858(0xee)](_0x53f281,_0x1f79c1,_0x471ac0){const _0x304351=_0xe14858;console['log'](_0x304351(0x9e));const _0x2f1929=Date[_0x304351(0xac)]();try{const _0x324c62=0xd,_0x226d77=0x2ee0,_0xffd946=0x1388,_0x452bb3=0x3c*0x3e8;let _0x3345f3=0x0,_0x4854b3=![],_0xb2250b=null;while(!_0xb2250b&&_0x3345f3<_0x324c62){console[_0x304351(0xb0)]('第\x20'+(_0x3345f3+0x1)+_0x304351(0x127));Date[_0x304351(0xac)]()-_0x2f1929>=_0x452bb3&&(_0x4854b3=!![]);await this['sleep'](_0x4854b3?_0xffd946:_0x226d77);const _0x4c6cc6=await this[_0x304351(0xdd)]();_0xb2250b=await this[_0x304351(0x126)](_0x4c6cc6,_0x471ac0,_0x1f79c1),_0x3345f3++;}if(!_0xb2250b)throw new common_1[(_0x304351(0xb4))](_0x304351(0xc8),common_1['HttpStatus']['BAD_REQUEST']);const _0x281ac6=Date[_0x304351(0xac)]();return console[_0x304351(0xb0)](_0x304351(0xe4)+Math[_0x304351(0xc1)]((_0x281ac6-_0x2f1929)/0x3e8)+'\x20S'),_0xb2250b;}catch(_0x81ff4c){console[_0x304351(0xdc)](_0x81ff4c[_0x304351(0xa2)]);throw new common_1[(_0x304351(0xb4))](_0x304351(0x9c),common_1['HttpStatus'][_0x304351(0x124)]);}}async[_0xe14858(0x126)](_0x2e2878,_0x30e030,_0x572d39){const _0x13160d=_0xe14858;if(!_0x2e2878||!_0x2e2878[_0x13160d(0xae)])return;console[_0x13160d(0xb0)]('本次比对的随机ID:\x20',_0x30e030);const _0x2bb470=_0x2e2878[_0x13160d(0xad)](_0x3e3012=>{const _0xc7fc26=_0x13160d,{attachments:attachments=[],content:_0xe16dd6,edited_timestamp:_0x1f5cdd}=_0x3e3012;return _0xe16dd6[_0xc7fc26(0xe7)](_0x30e030)&&attachments[_0xc7fc26(0xae)]>0x0&&!_0x1f5cdd&&!_0x572d39['includes'](_0x3e3012['id']);});return _0x2bb470||null;}async[_0xe14858(0xdd)](){const _0x553e3b=_0xe14858;try{const {application_id:_0x2f1399,guild_id:_0x415a3b,channel_id:_0x1ad5d4,session_id:_0x44a2ab,version:_0x5225e6,id:_0x267b27,authorization:_0x1baf1d,mjProxy:_0xaafe5b}=await this[_0x553e3b(0xdb)](),_0x4dc300=_0xaafe5b==0x1?_0x553e3b(0x108)+_0x1ad5d4:_0x553e3b(0xd6)+_0x1ad5d4+_0x553e3b(0xd0),_0x3d54da={'authorization':_0x1baf1d},_0x50f294=await axios_1[_0x553e3b(0x123)][_0x553e3b(0x95)](_0x4dc300,{'headers':_0x3d54da});return _0x50f294[_0x553e3b(0xcb)];}catch(_0x2ac9ce){console[_0x553e3b(0xb0)](_0x553e3b(0x146),_0x2ac9ce);throw new common_1[(_0x553e3b(0xb4))](_0x553e3b(0x106),common_1[_0x553e3b(0x12f)][_0x553e3b(0x134)]);}}async['sleep'](_0x12842c){return new Promise(_0x589a0c=>setTimeout(_0x589a0c,_0x12842c));}['extractContent'](_0x1371b2){const _0x5d411e=_0xe14858,_0x20d74e=_0x1371b2['match'](/\*\*(.+?)\*\*/),_0x57d364=_0x1371b2[_0x5d411e(0xce)](/- Image #(\d+)/);if(!_0x20d74e||!_0x57d364)return null;const _0x5c004b=_0x20d74e[0x1],_0x210618=parseInt(_0x57d364[0x1]);return{'prompt':_0x5c004b,'order':_0x210618};}async[_0xe14858(0xdb)](){const _0xba977e=_0xe14858,_0x288291=await this[_0xba977e(0xf1)][_0xba977e(0xef)]([_0xba977e(0xf6),_0xba977e(0xe3),_0xba977e(0xc6),_0xba977e(0x116),_0xba977e(0x112),_0xba977e(0x115),_0xba977e(0xaf),'mjRateLimit',_0xba977e(0xb8)]),_0x11caad={'application_id':_0x288291[_0xba977e(0xe3)],'guild_id':_0x288291[_0xba977e(0xc6)],'channel_id':_0x288291['mjChannelId'],'session_id':_0x288291[_0xba977e(0x112)],'version':_0x288291['mjVersion'],'id':_0x288291[_0xba977e(0xf6)],'authorization':_0x288291[_0xba977e(0xaf)],'mjRateLimit':_0x288291[_0xba977e(0xcd)],'mjProxy':_0x288291['mjProxy']||0x0};return _0x11caad;}['removeEmoji'](_0x5dce42){const _0x27db03=_0xe14858,_0x3e0df4=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return _0x5dce42[_0x27db03(0xd8)](_0x3e0df4,'');}async[_0xe14858(0x103)](_0x2e7436){const _0x30d808=_0xe14858,_0x17044b=await this[_0x30d808(0x143)][_0x30d808(0x113)]({'where':{'userId':_0x2e7436[_0x30d808(0x120)]['id']}}),{id:_0x42b73d,balance:_0x49d76b}=_0x17044b;if(!_0x49d76b||(_0x17044b===null||_0x17044b===void 0x0?void 0x0:_0x17044b[_0x30d808(0x132)])<0x1)throw new common_1[(_0x30d808(0xb4))]('您当前暂无MJ绘画余额',common_1['HttpStatus'][_0x30d808(0x134)]);}async[_0xe14858(0x99)](_0x4cb931){const _0x3bd3a2=_0xe14858,{id:_0x480916,role:_0xf964fd}=_0x4cb931[_0x3bd3a2(0x120)];!this['freeQueueUsers'][_0x480916]?this['freeQueueUsers'][_0x480916]=0x1:this[_0x3bd3a2(0x100)][_0x480916]=this[_0x3bd3a2(0x100)][_0x480916]+0x1,console[_0x3bd3a2(0xb0)](_0x3bd3a2(0x141)+_0x480916+_0x3bd3a2(0x101),this['freeQueueUsers'][_0x480916]);}async[_0xe14858(0xca)](_0x38559d){const _0x3b107e=_0xe14858,{id:_0x3724cc,role:_0x30dcaa}=_0x38559d['user'];if([_0x3b107e(0xe1),'super'][_0x3b107e(0xe7)](_0x30dcaa))return!![];const {mjRateLimit:_0x36e995}=await this[_0x3b107e(0xdb)]();if(this[_0x3b107e(0xb7)][_0x3724cc]){const _0x4b68be=this[_0x3b107e(0xb7)][_0x3724cc];if(_0x4b68be>Date['now']()){console[_0x3b107e(0xb0)](_0x3b107e(0x13f)+_0x3724cc+_0x3b107e(0xed));throw new common_1[(_0x3b107e(0xb4))](_0x3b107e(0xaa)+_0x36e995+_0x3b107e(0xff),common_1['HttpStatus'][_0x3b107e(0x134)]);}else this['rateLimits'][_0x3724cc]=Date['now']()+Number(_0x36e995)*0x3e8;}else{const _0xddd035=Date[_0x3b107e(0xac)]();this[_0x3b107e(0xb7)][_0x3724cc]=_0xddd035+0x3e8*Number(_0x36e995);}}async['deductBalance'](_0x329af8){const _0x3bdb67=_0xe14858;await this['balanceEntity'][_0x3bdb67(0xd9)]()[_0x3bdb67(0x13c)](balance_entity_1['BalanceEntity'])['set']({'balance':()=>_0x3bdb67(0x111)})[_0x3bdb67(0x145)]('userId\x20=\x20:userId',{'userId':_0x329af8[_0x3bdb67(0x120)]['id']})[_0x3bdb67(0x131)]();}async[_0xe14858(0xfe)](){return 0x1;}};MjService=__decorate([(0x0,common_1[_0xe14858(0xbb)])(),__param(0x0,(0x0,typeorm_2[_0xe14858(0x12e)])(chatLog_entity_1[_0xe14858(0x121)])),__param(0x1,(0x0,typeorm_2[_0xe14858(0x12e)])(balance_entity_1['BalanceEntity'])),__metadata('design:paramtypes',[typeorm_1['Repository'],typeorm_1['Repository'],upload_service_1[_0xe14858(0xe2)],chatLog_service_1[_0xe14858(0xc5)],globalConfig_service_1['GlobalConfigService'],fanyi_service_1[_0xe14858(0xa0)],badwords_service_1[_0xe14858(0xf9)]])],MjService),exports['MjService']=MjService;function _0x2c86(_0x294c1c,_0xb7a898){const _0x1a0b85=_0x1a0b();return _0x2c86=function(_0x2c86f4,_0xe18570){_0x2c86f4=_0x2c86f4-0x95;let _0x29a780=_0x1a0b85[_0x2c86f4];return _0x29a780;},_0x2c86(_0x294c1c,_0xb7a898);}function _0x1a0b(){const _0x17b7cf=['defineProperty','放大当前图片失败','本次放大图片的id:\x20','function','放大单张图片请求失败...','user','ChatLogEntity','draw','default','INTERNAL_SERVER_ERROR','DeductionKey','findCurrentPromptResult','\x20次开始查询','开始请求用户','metadata','变换图片任务结束\x20队列-1:\x20','历史记录中不存在当前图片、请确认您需要变换的图片是否存在','axios:\x20','开始轮询单张变换图片结果','InjectRepository','HttpStatus','typeorm','execute','balance','removeEmoji','BAD_REQUEST','MjService','prompt','randomId:\x20','imagine','__esModule','../../common/constants/balance.constant','getClientIp','update','开始请求变换图片\x20队列+1:\x20','5446288cDdNjy','当前用户\x20','pollForVariationResult','当前用户','sendDrawInteractions','balanceEntity','7104800DHmnaE','where','axios\x20get:\x20','3Pcoiti','get','Not','存入图片完成:\x20','http://172.247.48.137:8000/mj/draw','checkFree','__metadata','badwordsService','网络连接失败,请稍后再试!','绘画请求失败、当前使用人数过多、请稍后试试吧、排队中...','开始查询绘画结果轮询','\x20次开始查询[变换图片]','FanyiService','prompt\x20-------->\x20\x20','message','object','历史中存在当前图片、直接获取!','queueCount','message_id','createRandomUid','144294Uogjec','\x20队列+1:\x20','由于速率限制、当前普通用户限制为','enlargeWorking','now','find','length','mjAuthorization','log','历史记录中不存在当前图片、请确认您放大的图片是否存在','drawWorking','push','HttpException','orderId','parse','rateLimits','mjProxy','变换当前图片失败','enlarge','Injectable','convertToEnglish','__decorate','绘图指令完成','uploadFileFromUrl','error:\x20','floor','response','uploadService','../badwords/badwords.service','ChatLogService','mjGuildId','当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...','绘画超时,请稍后再试!','@nestjs/typeorm','checkRateLimit','data','sendSmInteractions','mjRateLimit','match','saveChatLog','/messages?limit=50','mjDraw','PAINT_TYPE','开始请求放大图片\x20队列+1:\x20','\x20次开始查询\x20=>\x20当前查询结果','10ewMyoN','https://discord.com/api/v9/channels/','mjNotSaveImg','replace','createQueryBuilder','绘制图片任务异常中断\x20队列-1:\x20','getMjDefaultParams','error','queryMessageList','max','https://discord.com/api/v9/interactions','extractContent','admin','UploadService','mjApplicationId','本次绘图耗时:\x20','pollForUpscaleResult','filter','includes','__param','IsNull','绘制图片任务结束\x20队列-1:\x20','变换当前图片超时!','29324pcSLqS','\x20请求过于频繁','pollForResult','getConfigs','当前图片没有绘画信息、无法放大!','globalConfigService','4092813HyLXla','29283562TEDFKS','axios','stringify','mjId','fanyiService','baiduFanyiAppId','BadwordsService','components','variationSingleImg','拿到了远程地址:\x20','variationId','test','秒请求一次、请合理使用!','freeQueueUsers','使用的次数:','decorate','checkAuth','查询期间出现错误:','16eqEAxp','查询绘制结果失败...','map','http://172.247.48.137:8000/mj/list?channel_id=','url','findCurrentEnlargeImgResult','绘画失败','chatLogService','当前图片没有绘画信息、无法变体!','post','3140445cSCSyM','绘画任务开始','balance\x20-\x201','mjSessionId','findOne','chatLogEntity','mjVersion','mjChannelId','发送放大指令成功','sleep','放大图片任务异常中断\x20队列-1:\x20','130Tsuuao'];_0x1a0b=function(){return _0x17b7cf;};return _0x1a0b();}