YiAi/YiAiQuickDeploy/dist/modules/mj/mj.service.js
2024-02-06 13:43:30 +08:00

1 line
29 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 _0x439e03=_0x1ef6;(function(_0x36c3ee,_0x49d348){const _0x205898=_0x1ef6,_0x15eb6c=_0x36c3ee();while(!![]){try{const _0x4a956f=-parseInt(_0x205898(0x19f))/0x1+parseInt(_0x205898(0x1d7))/0x2+parseInt(_0x205898(0x1cf))/0x3*(-parseInt(_0x205898(0x1ff))/0x4)+parseInt(_0x205898(0x19b))/0x5+parseInt(_0x205898(0x1af))/0x6+parseInt(_0x205898(0x220))/0x7+parseInt(_0x205898(0x1d5))/0x8*(-parseInt(_0x205898(0x1f2))/0x9);if(_0x4a956f===_0x49d348)break;else _0x15eb6c['push'](_0x15eb6c['shift']());}catch(_0x2e6745){_0x15eb6c['push'](_0x15eb6c['shift']());}}}(_0x4d02,0xc5341));function _0x1ef6(_0x122946,_0x41e9d7){const _0x4d0275=_0x4d02();return _0x1ef6=function(_0x1ef60d,_0x13c29c){_0x1ef60d=_0x1ef60d-0x183;let _0x44cd07=_0x4d0275[_0x1ef60d];return _0x44cd07;},_0x1ef6(_0x122946,_0x41e9d7);}var __decorate=this&&this[_0x439e03(0x1aa)]||function(_0x1144c7,_0x2550d0,_0x39110f,_0x33f3f1){const _0x3b54bf=_0x439e03;var _0x298889=arguments['length'],_0x2df45b=_0x298889<0x3?_0x2550d0:_0x33f3f1===null?_0x33f3f1=Object[_0x3b54bf(0x19d)](_0x2550d0,_0x39110f):_0x33f3f1,_0x50c9aa;if(typeof Reflect===_0x3b54bf(0x1c3)&&typeof Reflect[_0x3b54bf(0x1a9)]==='function')_0x2df45b=Reflect[_0x3b54bf(0x1a9)](_0x1144c7,_0x2550d0,_0x39110f,_0x33f3f1);else{for(var _0x14f38b=_0x1144c7[_0x3b54bf(0x21d)]-0x1;_0x14f38b>=0x0;_0x14f38b--)if(_0x50c9aa=_0x1144c7[_0x14f38b])_0x2df45b=(_0x298889<0x3?_0x50c9aa(_0x2df45b):_0x298889>0x3?_0x50c9aa(_0x2550d0,_0x39110f,_0x2df45b):_0x50c9aa(_0x2550d0,_0x39110f))||_0x2df45b;}return _0x298889>0x3&&_0x2df45b&&Object['defineProperty'](_0x2550d0,_0x39110f,_0x2df45b),_0x2df45b;},__metadata=this&&this[_0x439e03(0x1bb)]||function(_0x5b059c,_0x3bafde){const _0x5a4a0d=_0x439e03;if(typeof Reflect===_0x5a4a0d(0x1c3)&&typeof Reflect[_0x5a4a0d(0x1cd)]===_0x5a4a0d(0x21b))return Reflect[_0x5a4a0d(0x1cd)](_0x5b059c,_0x3bafde);},__param=this&&this[_0x439e03(0x1e9)]||function(_0x46f9a9,_0x55e05f){return function(_0x5d302a,_0x2d1d82){_0x55e05f(_0x5d302a,_0x2d1d82,_0x46f9a9);};};function _0x4d02(){const _0x5cd24e=['@nestjs/common','message_id','drawWorking','历史记录中不存在当前图片、请确认您放大的图片是否存在','badwordsService','__param','您当前暂无MJ绘画余额','https://discord.com/api/v9/channels/','saveChatLog','绘画失败','find','draw','checkBadWords','response','9HnOOJA','removeEmoji','replace','axios','发送放大指令成功','uploadFileFromUrl','放大图片任务结束\x20队列-1:\x20','../userBalance/balance.entity','sendDrawInteractions','本次放大图片的id:\x20','getConfigs','\x20请求过于频繁','BAD_REQUEST','152zkMPoE','绘画请求失败、当前使用人数过多、请稍后试试吧、排队中...','post','发送绘画指令结果:\x20','\x20队列+1:\x20','http://172.247.48.137:8000/mj/draw','IsNull','https://discord.com/api/v9/interactions','findOne','get','chatLogService','data','chatLogEntity','变换当前图片超时!','DeductionKey','imagine','checkAuth','findCurrentEnlargeImgResult','查询期间出现错误:','pollForResult','HttpStatus','message','BadwordsService','now','test','mjApplicationId','extractContent','baiduFanyiSecret','function','defineProperty','length','design:paramtypes','createRandomUid','6231463myYsmy','max','历史中存在当前图片、直接获取!','mjChannelId','randomId:\x20','绘画超时,请稍后再试!','uploadService','enlargeWorking','mjSessionId','prompt\x20-------->\x20\x20','mjGuildId','PAINT_TYPE','userId\x20=\x20:userId','../globalConfig/globalConfig.service','includes','checkFree','filter','开始请求变换图片\x20队列+1:\x20','ChatLogService','当前图片没有绘画信息、无法放大!','使用的次数:','rateLimits','../upload/upload.service','\x20次开始查询\x20=>\x20当前查询结果','queueCount','mjNotSaveImg','../badwords/badwords.service','存入图片完成:\x20','components','Like','balance','getMjDefaultParams','substring','map','findCurrentVariationImgResult','../../common/utils','../chatLog/chatLog.entity','variationId','sleep','match','deductBalance','由于速率限制、当前普通用户限制为','\x20次开始查询[变换图片]','mjProxy','当前用户\x20','6888980DusfbW','变化图片任务异常中断\x20队列-1:\x20','getOwnPropertyDescriptor','/messages?limit=50','868438vSMgGZ','freeQueueUsers','checkRateLimit','super','@nestjs/typeorm','秒请求一次、请合理使用!','error','globalConfigService','error:\x20','axios:\x20','decorate','__decorate','floor','sendSmInteractions','queryMessageList','getClientIp','9098520JIcRUL','MjService','INTERNAL_SERVER_ERROR','开始轮询单张变换图片结果','绘制图片任务结束\x20队列-1:\x20','user','绘制图片任务异常中断\x20队列-1:\x20','变换当前图片失败','绘画任务开始','mjRateLimit','default','绘图指令完成','__metadata','where','http://172.247.48.137:8000/mj/list?channel_id=','fanyiService','findCurrentPromptResult','admin','parse','mjId','object','历史这些id已经被获取过了\x20不能拿了:\x20','UploadService','variationSingleImg','__esModule','typeorm','拿到了远程地址:\x20','开始查询绘画结果轮询','enlarge','log','metadata','balanceEntity','30828BcyIlR','mjAuthorization','stringify','execute','ChatLogEntity','HttpException','15900392LPaUFe','开始请求用户','539590MBpfXq','pollForUpscaleResult','prompt','InjectRepository','当前图片已经放大过了、请勿重复放大!','Repository','orderId','axios\x20get:\x20','网络连接失败,请稍后再试!','../chatLog/chatLog.service','当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...','url','历史记录中不存在当前图片、请确认您需要变换的图片是否存在'];_0x4d02=function(){return _0x5cd24e;};return _0x4d02();}Object[_0x439e03(0x21c)](exports,_0x439e03(0x1c7),{'value':!![]}),exports[_0x439e03(0x1b0)]=void 0x0;const globalConfig_service_1=require(_0x439e03(0x22d)),upload_service_1=require(_0x439e03(0x184)),common_1=require(_0x439e03(0x1e4)),axios_1=require(_0x439e03(0x1f5)),chatLog_service_1=require(_0x439e03(0x1e0)),balance_constant_1=require('../../common/constants/balance.constant'),utils_1=require(_0x439e03(0x191)),chatLog_entity_1=require(_0x439e03(0x192)),typeorm_1=require(_0x439e03(0x1c8)),typeorm_2=require(_0x439e03(0x1a3)),balance_entity_1=require(_0x439e03(0x1f9)),fanyi_service_1=require('../fanyi/fanyi.service'),badwords_service_1=require(_0x439e03(0x188));let MjService=class MjService{constructor(_0x9665b5,_0x29f920,_0x8c8a62,_0x3c0dd8,_0x4d186d,_0x5dc34c,_0x1aac33){const _0x2ce2c2=_0x439e03;this[_0x2ce2c2(0x20b)]=_0x9665b5,this['balanceEntity']=_0x29f920,this[_0x2ce2c2(0x226)]=_0x8c8a62,this['chatLogService']=_0x3c0dd8,this[_0x2ce2c2(0x1a6)]=_0x4d186d,this['fanyiService']=_0x5dc34c,this['badwordsService']=_0x1aac33,this['rateLimits']={},this['drawWorking']=[],this[_0x2ce2c2(0x227)]=[],this[_0x2ce2c2(0x186)]=0x0,this[_0x2ce2c2(0x1a0)]={};}async['mjDraw'](_0x5aec66){const _0x4de1f3=_0x439e03,{jobId:_0x3dd84d,prompt:_0x538097,startTime:_0x2a159b,userId:_0x587d28}=_0x5aec66;return console[_0x4de1f3(0x1cc)](_0x4de1f3(0x1b7),'mjservice'),await new Promise(_0x2d0b15=>setTimeout(_0x2d0b15,0x1388)),{'a':0x1,'b':0x2};}async[_0x439e03(0x1ef)](_0x59e8b4,_0x2d7362){const _0x5adf27=_0x439e03;await this['checkAuth'](_0x2d7362),await this[_0x5adf27(0x1e8)][_0x5adf27(0x1f0)](_0x59e8b4[_0x5adf27(0x1d9)],_0x2d7362[_0x5adf27(0x1b4)]['id']);const _0x32f37d=_0x59e8b4[_0x5adf27(0x1d9)];let _0x4997eb=_0x59e8b4[_0x5adf27(0x1d9)];const {baiduFanyiAppId:_0x597a90,baiduFanyiSecret:_0x1f68dc}=await this[_0x5adf27(0x1a6)][_0x5adf27(0x1fc)](['baiduFanyiAppId',_0x5adf27(0x21a)]);_0x597a90&&_0x1f68dc&&(_0x4997eb=await this[_0x5adf27(0x1be)]['convertToEnglish'](_0x32f37d));const _0x5abc3d='['+(0x0,utils_1[_0x5adf27(0x21f)])()+']',_0x86b897=_0x5abc3d+'\x20'+_0x4997eb;console[_0x5adf27(0x1cc)](_0x5adf27(0x224),_0x5abc3d),console[_0x5adf27(0x1cc)](_0x5adf27(0x229),_0x86b897);const _0x197f95=this[_0x5adf27(0x1e6)][_0x5adf27(0x1ee)](_0x5a1a88=>_0x5a1a88[_0x5adf27(0x22e)](_0x59e8b4[_0x5adf27(0x1d9)]));if(_0x197f95)throw new common_1['HttpException']('当前提示词已经在任务队列中了、请勿重复提交。。。',common_1[_0x5adf27(0x213)][_0x5adf27(0x1fe)]);if(this[_0x5adf27(0x186)]>=0x3)throw new common_1['HttpException']('当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...',common_1[_0x5adf27(0x213)][_0x5adf27(0x1fe)]);await this['checkRateLimit'](_0x2d7362),this['queueCount']++,console[_0x5adf27(0x1cc)](_0x5adf27(0x1d6)+_0x2d7362['user']['id']+_0x5adf27(0x203),this[_0x5adf27(0x186)]);try{const _0x381982=await this[_0x5adf27(0x20b)][_0x5adf27(0x1ee)]({'where':{'prompt':(0x0,typeorm_1[_0x5adf27(0x18b)])('%'+_0x86b897+'%')}}),_0x569417=_0x381982['map'](_0x34ba75=>_0x34ba75[_0x5adf27(0x1e5)]);this[_0x5adf27(0x1e6)]['push'](_0x86b897);let _0x14311b;const _0x142eb3=await this[_0x5adf27(0x1fa)](_0x86b897,_0x569417,_0x5abc3d);_0x142eb3?(console[_0x5adf27(0x1cc)](_0x5adf27(0x222)),_0x14311b=_0x142eb3):_0x14311b=await this[_0x5adf27(0x212)](_0x86b897,_0x569417,_0x5abc3d);this['queueCount']--,this[_0x5adf27(0x186)]<0x0&&(this[_0x5adf27(0x186)]=0x0),console[_0x5adf27(0x1cc)](_0x5adf27(0x1b3),this[_0x5adf27(0x186)]);const {id:_0x9fe1c4,content:_0x5cb4c3,channel_id:_0x14b80e,attachments:attachments=[],timestamp:_0x52d3fb}=_0x14311b;if(!attachments[_0x5adf27(0x21d)]||!attachments[0x0][_0x5adf27(0x1e2)])throw new common_1[(_0x5adf27(0x1d4))](_0x5adf27(0x1ed),common_1[_0x5adf27(0x213)][_0x5adf27(0x1fe)]);const {filename:_0x237ed8,url:_0xc9c584,width:_0x4cf5c2,height:_0x16be2c,size:_0x1d680c}=attachments[0x0];console[_0x5adf27(0x1cc)](_0x5adf27(0x1c9),_0xc9c584);const _0x1b9bd7=this['globalConfigService'][_0x5adf27(0x1fc)]([_0x5adf27(0x187)]);let _0x1a465d='';(!Number(_0x1b9bd7)||Number(_0x1b9bd7)===0x0)&&(_0x1a465d=await this[_0x5adf27(0x226)][_0x5adf27(0x1f7)]({'filename':_0x237ed8,'url':_0xc9c584}),console['log']('存入图片完成:\x20',_0x1a465d));const _0x170ca4={'curIp':(0x0,utils_1[_0x5adf27(0x1ae)])(_0x2d7362),'userId':_0x2d7362[_0x5adf27(0x1b4)]['id'],'type':balance_constant_1[_0x5adf27(0x20d)][_0x5adf27(0x22b)],'prompt':_0x86b897,'answer':_0x1a465d,'model':'mj','extend':this[_0x5adf27(0x1f3)](JSON[_0x5adf27(0x1d1)](_0x14311b)),'message_id':_0x9fe1c4,'variationId':_0x9fe1c4,'upscaleId':_0x9fe1c4,'group':0x1,'isSaveImg':!Number(_0x1b9bd7)||Number(_0x1b9bd7)===0x0,'fileInfo':JSON[_0x5adf27(0x1d1)]({'width':_0x4cf5c2,'height':_0x16be2c,'size':_0x1d680c,'filename':_0x237ed8,'cosUrl':_0x1a465d})};return await this[_0x5adf27(0x209)]['saveChatLog'](_0x170ca4),await this[_0x5adf27(0x196)](_0x2d7362),this[_0x5adf27(0x1e6)]=this[_0x5adf27(0x1e6)][_0x5adf27(0x230)](_0x5c42b5=>_0x5c42b5!==_0x59e8b4[_0x5adf27(0x1d9)]),_0x1a465d;}catch(_0x174340){this['queueCount']--,this[_0x5adf27(0x186)]<0x0&&(this[_0x5adf27(0x186)]=0x0),console['log'](_0x5adf27(0x1b5),this[_0x5adf27(0x186)]),this[_0x5adf27(0x1e6)]=this['drawWorking'][_0x5adf27(0x230)](_0x285712=>_0x285712!==_0x59e8b4[_0x5adf27(0x1d9)]);throw new common_1[(_0x5adf27(0x1d4))](_0x174340[_0x5adf27(0x1f1)],common_1[_0x5adf27(0x213)][_0x5adf27(0x1fe)]);}}async['upscaleSingleImg'](_0x1ce83b,_0x3d40c2){const _0x3fd365=_0x439e03;if(this[_0x3fd365(0x186)]>=0x3)throw new common_1['HttpException'](_0x3fd365(0x1e1),common_1[_0x3fd365(0x213)]['BAD_REQUEST']);this[_0x3fd365(0x186)]++,console[_0x3fd365(0x1cc)]('用户'+_0x3d40c2[_0x3fd365(0x1b4)]['id']+'开始请求放大图片\x20队列+1:\x20',this[_0x3fd365(0x186)]);const {message_id:_0x461be5,orderId:_0x534a52}=_0x1ce83b;try{const _0x46b45e=await this[_0x3fd365(0x20b)]['findOne']({'where':{'message_id':_0x461be5}});if(!_0x46b45e)throw new common_1[(_0x3fd365(0x1d4))](_0x3fd365(0x1e7),common_1[_0x3fd365(0x213)][_0x3fd365(0x1fe)]);const _0x10f35f=await this[_0x3fd365(0x20b)][_0x3fd365(0x207)]({'where':{'upscaleId':_0x461be5,'action':'enlarge','orderId':_0x534a52}});if(_0x10f35f)throw new common_1[(_0x3fd365(0x1d4))](_0x3fd365(0x1db),common_1['HttpStatus'][_0x3fd365(0x1fe)]);const {prompt:_0x407643,extend:_0x51b8d2}=_0x46b45e;let _0x54d63e=null;try{_0x54d63e=JSON['parse'](_0x51b8d2);}catch(_0x5bca76){_0x54d63e=[];}const {components:components=[]}=_0x54d63e;if(!components['length'])throw new common_1[(_0x3fd365(0x1d4))](_0x3fd365(0x233),common_1[_0x3fd365(0x213)]['BAD_REQUEST']);const _0x2e4579=components[0x0][_0x3fd365(0x18a)][_0x534a52-0x1],{custom_id:_0x3e85a7}=_0x2e4579;console[_0x3fd365(0x1cc)]('放大custom_id:\x20',_0x3e85a7);const _0x24ed49={'message_id':_0x461be5,'custom_id':_0x3e85a7,'prompt':_0x407643,'orderId':_0x534a52};await this[_0x3fd365(0x1ac)](_0x24ed49),console[_0x3fd365(0x1cc)](_0x3fd365(0x1f6));const _0x263c52=await this[_0x3fd365(0x20b)][_0x3fd365(0x1ee)]({'where':{'prompt':(0x0,typeorm_1[_0x3fd365(0x18b)])('%'+_0x407643+'%')}}),_0x1dbc23=_0x263c52[_0x3fd365(0x18f)](_0x44be11=>_0x44be11['message_id']);console['log'](_0x3fd365(0x1c4),_0x1dbc23);const _0x472c90=await this[_0x3fd365(0x1d8)](_0x24ed49,_0x1dbc23);this[_0x3fd365(0x186)]--,this[_0x3fd365(0x186)]<0x0&&(this[_0x3fd365(0x186)]=0x0),console[_0x3fd365(0x1cc)](_0x3fd365(0x1f8),this[_0x3fd365(0x186)]);const {id:_0x18b098,content:_0x37f9e5,channel_id:_0x5a4a33,attachments:attachments=[],timestamp:_0x490325}=_0x472c90;if(!attachments[_0x3fd365(0x21d)]||!attachments[0x0]['url'])throw new common_1[(_0x3fd365(0x1d4))]('放大当前图片失败',common_1[_0x3fd365(0x213)][_0x3fd365(0x1fe)]);const {filename:_0x4f2d00,url:_0x43c42d,width:_0x5a829d,height:_0x2dc673,size:_0x13275c}=attachments[0x0],_0x74de10=this['globalConfigService'][_0x3fd365(0x1fc)]([_0x3fd365(0x187)]);let _0x53992b='';(!Number(_0x74de10)||Number(_0x74de10)===0x0)&&(_0x53992b=await this[_0x3fd365(0x226)]['uploadFileFromUrl']({'filename':_0x4f2d00,'url':_0x43c42d}),console[_0x3fd365(0x1cc)]('存入图片完成:\x20',_0x53992b));const _0x32169b={'curIp':(0x0,utils_1[_0x3fd365(0x1ae)])(_0x3d40c2),'userId':_0x3d40c2[_0x3fd365(0x1b4)]['id'],'type':balance_constant_1[_0x3fd365(0x20d)][_0x3fd365(0x22b)],'prompt':_0x407643,'answer':_0x53992b,'model':'mj','extend':this[_0x3fd365(0x1f3)](JSON[_0x3fd365(0x1d1)](_0x472c90)),'message_id':_0x461be5,'upscaleId':_0x18b098,'variationId':_0x18b098,'action':_0x3fd365(0x1cb),'orderId':_0x24ed49[_0x3fd365(0x1dd)],'isSaveImg':!Number(_0x74de10)||Number(_0x74de10)===0x0,'fileInfo':JSON['stringify']({'width':_0x5a829d,'height':_0x2dc673,'size':_0x13275c,'filename':_0x4f2d00,'cosUrl':_0x53992b})};return await this['chatLogService'][_0x3fd365(0x1ec)](_0x32169b),_0x53992b;}catch(_0x48d385){console[_0x3fd365(0x1cc)]('error:\x20',_0x48d385),this['queueCount']--,this[_0x3fd365(0x186)]<0x0&&(this['queueCount']=0x0),console[_0x3fd365(0x1cc)]('放大图片任务异常中断\x20队列-1:\x20',this[_0x3fd365(0x186)]);throw new common_1[(_0x3fd365(0x1d4))](_0x48d385[_0x3fd365(0x1f1)],common_1['HttpStatus'][_0x3fd365(0x1fe)]);}}async[_0x439e03(0x1c6)](_0x4ee9a2,_0x23ebaa){const _0x41e8dd=_0x439e03;if(this[_0x41e8dd(0x186)]>=0x3)throw new common_1['HttpException'](_0x41e8dd(0x1e1),common_1[_0x41e8dd(0x213)][_0x41e8dd(0x1fe)]);await this[_0x41e8dd(0x20f)](_0x23ebaa),await this['checkRateLimit'](_0x23ebaa),this[_0x41e8dd(0x186)]++,console[_0x41e8dd(0x1cc)]('用户'+_0x23ebaa['user']['id']+_0x41e8dd(0x231),this['queueCount']);const {message_id:_0x52b65a,orderId:_0x5c218e}=_0x4ee9a2;try{const _0x1b9695=await this[_0x41e8dd(0x20b)][_0x41e8dd(0x207)]({'where':{'message_id':_0x52b65a}});if(!_0x1b9695)throw new common_1[(_0x41e8dd(0x1d4))](_0x41e8dd(0x1e3),common_1['HttpStatus'][_0x41e8dd(0x1fe)]);const {prompt:_0x1f2612,extend:_0x494d14}=_0x1b9695;let _0x108260=null;try{_0x108260=JSON[_0x41e8dd(0x1c1)](_0x494d14);}catch(_0x48f9c6){_0x108260=[];}const {components:components=[]}=_0x108260;if(!components[_0x41e8dd(0x21d)])throw new common_1[(_0x41e8dd(0x1d4))]('当前图片没有绘画信息、无法变体!',common_1[_0x41e8dd(0x213)]['BAD_REQUEST']);const _0x3e7360=components[0x1][_0x41e8dd(0x18a)][_0x5c218e-0x1],{custom_id:_0x5183a9}=_0x3e7360,_0x191f70=await this[_0x41e8dd(0x20b)][_0x41e8dd(0x1ee)]({'where':{'variationId':(0x0,typeorm_1['Not'])((0x0,typeorm_1[_0x41e8dd(0x205)])()),'prompt':(0x0,typeorm_1[_0x41e8dd(0x18b)])('%'+_0x1f2612+'%')}}),_0x595ca7=_0x191f70['map'](_0x4a19b6=>_0x4a19b6[_0x41e8dd(0x193)]),_0x1f598c={'message_id':_0x52b65a,'custom_id':_0x5183a9,'prompt':_0x1f2612,'orderId':_0x5c218e};await this[_0x41e8dd(0x1ac)](_0x1f598c);const _0x3bf093=await this['pollForVariationResult'](_0x1f598c,_0x595ca7);this[_0x41e8dd(0x186)]--,this['queueCount']<0x0&&(this[_0x41e8dd(0x186)]=0x0),console['log']('变换图片任务结束\x20队列-1:\x20',this[_0x41e8dd(0x186)]);const {id:_0x37b8a8,content:_0x59ebe6,channel_id:_0x435a36,attachments:attachments=[],timestamp:_0x2fbef8}=_0x3bf093;if(!attachments[_0x41e8dd(0x21d)]||!attachments[0x0][_0x41e8dd(0x1e2)])throw new common_1[(_0x41e8dd(0x1d4))](_0x41e8dd(0x1b6),common_1[_0x41e8dd(0x213)][_0x41e8dd(0x1fe)]);const {filename:_0x4e11df,url:_0x403524,width:_0x58b4da,height:_0x32daf6,size:_0x117756}=attachments[0x0],_0x217698=this[_0x41e8dd(0x1a6)]['getConfigs']([_0x41e8dd(0x187)]);let _0x58c92b='';(!Number(_0x217698)||Number(_0x217698)===0x0)&&(_0x58c92b=await this['uploadService'][_0x41e8dd(0x1f7)]({'filename':_0x4e11df,'url':_0x403524}),console['log'](_0x41e8dd(0x189),_0x58c92b));const _0x3d5f98={'curIp':(0x0,utils_1[_0x41e8dd(0x1ae)])(_0x23ebaa),'userId':_0x23ebaa[_0x41e8dd(0x1b4)]['id'],'type':balance_constant_1[_0x41e8dd(0x20d)][_0x41e8dd(0x22b)],'prompt':_0x1f2612,'answer':_0x58c92b,'model':'mj','group':0x1,'extend':this[_0x41e8dd(0x1f3)](JSON[_0x41e8dd(0x1d1)](_0x3bf093)),'message_id':_0x37b8a8,'upscaleId':_0x37b8a8,'variationId':_0x37b8a8,'action':_0x41e8dd(0x1cb),'orderId':_0x1f598c[_0x41e8dd(0x1dd)],'isSaveImg':!Number(_0x217698)||Number(_0x217698)===0x0,'fileInfo':JSON['stringify']({'width':_0x58b4da,'height':_0x32daf6,'size':_0x117756,'filename':_0x4e11df,'cosUrl':_0x58c92b})};return await this[_0x41e8dd(0x209)][_0x41e8dd(0x1ec)](_0x3d5f98),_0x58c92b;}catch(_0x14f58a){console[_0x41e8dd(0x1cc)](_0x41e8dd(0x1a7),_0x14f58a),this[_0x41e8dd(0x186)]--,this[_0x41e8dd(0x186)]<0x0&&(this[_0x41e8dd(0x186)]=0x0),console[_0x41e8dd(0x1cc)](_0x41e8dd(0x19c),this['queueCount']);throw new common_1['HttpException'](_0x14f58a['response'],common_1[_0x41e8dd(0x213)]['BAD_REQUEST']);}}async[_0x439e03(0x1ac)](_0x107d7f){const _0x33498e=_0x439e03,{message_id:_0x961016,custom_id:_0x516b8f}=_0x107d7f,{application_id:_0x2acda9,guild_id:_0x2dcf71,channel_id:_0x35ca82,session_id:_0x5bc08a,version:_0x3321be,id:_0x2b45f6,authorization:_0x1f31ed,mjProxy:_0x322cf6}=await this['getMjDefaultParams'](),_0x1be8cf=_0x322cf6==0x1?_0x33498e(0x204):_0x33498e(0x206),_0x210058={'authorization':_0x1f31ed},_0x5877e2={'type':0x3,'guild_id':_0x2dcf71,'channel_id':_0x35ca82,'message_flags':0x0,'message_id':_0x961016,'application_id':_0x2acda9,'session_id':_0x5bc08a,'data':{'component_type':0x2,'custom_id':_0x516b8f}};try{await axios_1[_0x33498e(0x1b9)]['post'](_0x1be8cf,_0x5877e2,{'headers':_0x210058}),console[_0x33498e(0x1cc)](_0x33498e(0x1ba));}catch(_0x31c994){console[_0x33498e(0x1cc)](_0x33498e(0x1a7),_0x31c994);throw new common_1[(_0x33498e(0x1d4))]('放大单张图片请求失败...',common_1[_0x33498e(0x213)][_0x33498e(0x1fe)]);}}async[_0x439e03(0x1d8)](_0x5eeb45,_0xd425b){const _0x32e394=_0x439e03,{message_id:_0x470ce7,custom_id:_0x3a8131,prompt:_0x5077b3,orderId:_0x4485eb}=_0x5eeb45;let _0x5a04e4=null,_0x363404=0x0;while(!_0x5a04e4&&_0x363404<0xa){try{const _0x4c7e95=Date['now'](),_0x37a282=await this[_0x32e394(0x1ad)]();console[_0x32e394(0x1cc)]('第\x20'+(_0x363404+0x1)+_0x32e394(0x185)+_0x37a282[_0x32e394(0x21d)]);_0x37a282&&_0x37a282['length']&&(_0x5a04e4=await this[_0x32e394(0x210)](_0x37a282,_0x5eeb45,_0xd425b));const _0x407bab=Date[_0x32e394(0x216)]()-_0x4c7e95,_0x1cf834=0xbb8;await this[_0x32e394(0x194)](Math['max'](_0x1cf834-_0x407bab,0x0)),_0x363404++;}catch(_0x2dbaf6){console[_0x32e394(0x1a5)]('查询期间出现错误:'+_0x2dbaf6['message']);}}return _0x5a04e4;}async['pollForVariationResult'](_0x3ebc17,_0x19fb92){const _0x5dc4bc=_0x439e03,{message_id:_0x374842,custom_id:_0x1f89a2,prompt:_0x4356f5,orderId:_0x3c109c}=_0x3ebc17;console[_0x5dc4bc(0x1cc)](_0x5dc4bc(0x1b2));let _0x2d3143=null,_0x445dfb=0x0;while(!_0x2d3143&&_0x445dfb<0xa){try{console[_0x5dc4bc(0x1cc)]('第\x20'+(_0x445dfb+0x1)+_0x5dc4bc(0x198));const _0x30f534=Date[_0x5dc4bc(0x216)](),_0x5953a2=await this[_0x5dc4bc(0x1ad)]();_0x5953a2&&_0x5953a2[_0x5dc4bc(0x21d)]&&(_0x2d3143=await this['findCurrentVariationImgResult'](_0x5953a2,_0x3ebc17,_0x19fb92));const _0x231e6a=Date['now']()-_0x30f534,_0x28ad28=0x1f40;await this['sleep'](Math[_0x5dc4bc(0x221)](_0x28ad28-_0x231e6a,0x0)),_0x445dfb++;}catch(_0x59acee){console[_0x5dc4bc(0x1a5)](_0x5dc4bc(0x211)+_0x59acee[_0x5dc4bc(0x214)]);}}if(!_0x2d3143)throw new common_1[(_0x5dc4bc(0x1d4))](_0x5dc4bc(0x20c),common_1[_0x5dc4bc(0x213)][_0x5dc4bc(0x1fe)]);return _0x2d3143;}async[_0x439e03(0x210)](_0x3182ea,_0xe72521,_0x39a578){const _0x7e82f4=_0x439e03,{message_id:_0x4cdfb3,custom_id:_0x124ba6,prompt:_0xa5b5ef,orderId:_0x1a37a1}=_0xe72521,_0x2347e8=_0xa5b5ef[_0x7e82f4(0x18e)](0x0,0xc);console[_0x7e82f4(0x1cc)](_0x7e82f4(0x1fb),_0x2347e8);const _0x172575=_0x3182ea[_0x7e82f4(0x1ee)](_0x468776=>{const _0x4703d4=_0x7e82f4,{content:_0x4462b0}=_0x468776;if(!this[_0x4703d4(0x219)](_0x4462b0))return![];const {prompt:_0x354654,order:_0x5cba5c}=this[_0x4703d4(0x219)](_0x4462b0);return _0x354654[_0x4703d4(0x22e)](_0x2347e8)&&_0xe72521[_0x4703d4(0x1dd)]===_0x5cba5c&&!_0x39a578[_0x4703d4(0x22e)](_0x468776['id']);});return _0x172575;}async[_0x439e03(0x190)](_0x3bcbe6,_0x9e057c,_0x5975a8){const _0x6b863c=_0x439e03,{message_id:_0xe752d4,custom_id:_0x28d40d,prompt:_0x4e82bf,orderId:_0x5ce994}=_0x9e057c,_0x3a5c97=_0x4e82bf[_0x6b863c(0x18e)](0x0,0xc),_0x2a6b15=_0x3bcbe6[_0x6b863c(0x1ee)](_0x3dae96=>{const _0x514620=_0x6b863c,{content:_0x349482}=_0x3dae96,_0x288a6f=_0x349482[_0x514620(0x195)](/\*\*(.+?)\*\*/),_0x5505c0=_0x288a6f?_0x288a6f[0x1]:'';if(!_0x5505c0)return![];return _0x5505c0[_0x514620(0x22e)](_0x3a5c97)&&!_0x5975a8[_0x514620(0x22e)](_0x3dae96['id']);});return _0x2a6b15;}async[_0x439e03(0x1fa)](_0x5df45a,_0x207068,_0x5c9262){const _0x56f32b=_0x439e03,_0x3cd0c6=await this[_0x56f32b(0x1ad)](),_0x5e4cf2=await this[_0x56f32b(0x1bf)](_0x3cd0c6,_0x5c9262,_0x207068);if(_0x5e4cf2)return console[_0x56f32b(0x1cc)]('有历史信息之间返回:\x20',_0x5e4cf2),_0x5e4cf2;const {application_id:_0x58d658,guild_id:_0x46a635,channel_id:_0x1d86b4,session_id:_0x1b0198,version:_0x2a90f5,id:_0x41b4a0,authorization:_0x3f9e59,mjProxy:_0x5b65ae}=await this['getMjDefaultParams'](),_0x69ccfb={'type':0x2,'application_id':_0x58d658,'guild_id':_0x46a635,'channel_id':_0x1d86b4,'session_id':_0x1b0198,'data':{'version':_0x2a90f5,'id':_0x41b4a0,'name':_0x56f32b(0x20e),'type':0x1,'options':[{'type':0x3,'name':'prompt','value':_0x5df45a}],'attachments':[]}};try{const _0x465885=_0x5b65ae==0x1?_0x56f32b(0x204):_0x56f32b(0x206),_0xfbb6a3={'authorization':_0x3f9e59},_0x2ca8f1=await axios_1[_0x56f32b(0x1b9)][_0x56f32b(0x201)](_0x465885,_0x69ccfb,{'headers':_0xfbb6a3});return console['log'](_0x56f32b(0x202),_0x2ca8f1[_0x56f32b(0x20a)]),![];}catch(_0x2333d3){console[_0x56f32b(0x1cc)](_0x56f32b(0x1a8),_0x2333d3);throw new common_1[(_0x56f32b(0x1d4))](_0x56f32b(0x200),common_1['HttpStatus'][_0x56f32b(0x1fe)]);}}async['pollForResult'](_0x90b7ce,_0x2862e9,_0x18a35d){const _0x4dfaf3=_0x439e03;console[_0x4dfaf3(0x1cc)](_0x4dfaf3(0x1ca));const _0x3db362=Date[_0x4dfaf3(0x216)]();try{const _0x1c2d0e=0xd,_0x5b897a=0x2ee0,_0x3d2b93=0x1388,_0x213211=0x3c*0x3e8;let _0x39c490=0x0,_0x5899a3=![],_0x489ad8=null;while(!_0x489ad8&&_0x39c490<_0x1c2d0e){console[_0x4dfaf3(0x1cc)]('第\x20'+(_0x39c490+0x1)+'\x20次开始查询');Date['now']()-_0x3db362>=_0x213211&&(_0x5899a3=!![]);await this[_0x4dfaf3(0x194)](_0x5899a3?_0x3d2b93:_0x5b897a);const _0x2f1fbc=await this[_0x4dfaf3(0x1ad)]();_0x489ad8=await this[_0x4dfaf3(0x1bf)](_0x2f1fbc,_0x18a35d,_0x2862e9),_0x39c490++;}if(!_0x489ad8)throw new common_1['HttpException'](_0x4dfaf3(0x225),common_1[_0x4dfaf3(0x213)][_0x4dfaf3(0x1fe)]);const _0x2782d5=Date[_0x4dfaf3(0x216)]();return console[_0x4dfaf3(0x1cc)]('本次绘图耗时:\x20'+Math[_0x4dfaf3(0x1ab)]((_0x2782d5-_0x3db362)/0x3e8)+'\x20S'),_0x489ad8;}catch(_0x3f7d68){console[_0x4dfaf3(0x1a5)](_0x3f7d68[_0x4dfaf3(0x214)]);throw new common_1[(_0x4dfaf3(0x1d4))](_0x4dfaf3(0x1df),common_1[_0x4dfaf3(0x213)][_0x4dfaf3(0x1b1)]);}}async[_0x439e03(0x1bf)](_0x338a42,_0xee5d32,_0x28d8c2){const _0x4db85e=_0x439e03;if(!_0x338a42||!_0x338a42[_0x4db85e(0x21d)])return;console['log']('本次比对的随机ID:\x20',_0xee5d32);const _0x532f4c=_0x338a42[_0x4db85e(0x1ee)](_0x59a31b=>{const _0x1d539a=_0x4db85e,{attachments:attachments=[],content:_0x2a1868,edited_timestamp:_0x59f2f7}=_0x59a31b;return _0x2a1868[_0x1d539a(0x22e)](_0xee5d32)&&attachments[_0x1d539a(0x21d)]>0x0&&!_0x59f2f7&&!_0x28d8c2[_0x1d539a(0x22e)](_0x59a31b['id']);});return _0x532f4c||null;}async[_0x439e03(0x1ad)](){const _0x7c889=_0x439e03;try{const {application_id:_0x1c9d6c,guild_id:_0x2c58fa,channel_id:_0x3333b1,session_id:_0x2d3af0,version:_0x2c89c2,id:_0x383782,authorization:_0x1dc8ee,mjProxy:_0x541556}=await this[_0x7c889(0x18d)](),_0x438171=_0x541556==0x1?_0x7c889(0x1bd)+_0x3333b1:_0x7c889(0x1eb)+_0x3333b1+_0x7c889(0x19e),_0x552a8a={'authorization':_0x1dc8ee},_0x5e68a6=await axios_1[_0x7c889(0x1b9)][_0x7c889(0x208)](_0x438171,{'headers':_0x552a8a});return _0x5e68a6[_0x7c889(0x20a)];}catch(_0x1f053c){console[_0x7c889(0x1cc)](_0x7c889(0x1de),_0x1f053c);throw new common_1[(_0x7c889(0x1d4))]('查询绘制结果失败...',common_1[_0x7c889(0x213)][_0x7c889(0x1fe)]);}}async[_0x439e03(0x194)](_0x2b7e46){return new Promise(_0x2814d8=>setTimeout(_0x2814d8,_0x2b7e46));}[_0x439e03(0x219)](_0x197b43){const _0x3ed095=_0x439e03,_0x33badb=_0x197b43['match'](/\*\*(.+?)\*\*/),_0x245a48=_0x197b43[_0x3ed095(0x195)](/- Image #(\d+)/);if(!_0x33badb||!_0x245a48)return null;const _0x2cd5a6=_0x33badb[0x1],_0x152366=parseInt(_0x245a48[0x1]);return{'prompt':_0x2cd5a6,'order':_0x152366};}async['getMjDefaultParams'](){const _0x2ed594=_0x439e03,_0x381f3c=await this[_0x2ed594(0x1a6)][_0x2ed594(0x1fc)]([_0x2ed594(0x1c2),_0x2ed594(0x218),_0x2ed594(0x22a),_0x2ed594(0x223),_0x2ed594(0x228),'mjVersion','mjAuthorization',_0x2ed594(0x1b8),_0x2ed594(0x199)]),_0x5dce15={'application_id':_0x381f3c[_0x2ed594(0x218)],'guild_id':_0x381f3c['mjGuildId'],'channel_id':_0x381f3c['mjChannelId'],'session_id':_0x381f3c[_0x2ed594(0x228)],'version':_0x381f3c['mjVersion'],'id':_0x381f3c[_0x2ed594(0x1c2)],'authorization':_0x381f3c[_0x2ed594(0x1d0)],'mjRateLimit':_0x381f3c[_0x2ed594(0x1b8)],'mjProxy':_0x381f3c['mjProxy']||0x0};return _0x5dce15;}[_0x439e03(0x1f3)](_0x453f2f){const _0x456910=_0x439e03,_0x3538b4=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return _0x453f2f[_0x456910(0x1f4)](_0x3538b4,'');}async[_0x439e03(0x20f)](_0x4ede08){const _0x47b3e3=_0x439e03,_0x4bba5c=await this['balanceEntity']['findOne']({'where':{'userId':_0x4ede08[_0x47b3e3(0x1b4)]['id']}}),{id:_0xc1fe48,balance:_0x1078ad}=_0x4bba5c;if(!_0x1078ad||(_0x4bba5c===null||_0x4bba5c===void 0x0?void 0x0:_0x4bba5c[_0x47b3e3(0x18c)])<0x1)throw new common_1['HttpException'](_0x47b3e3(0x1ea),common_1[_0x47b3e3(0x213)][_0x47b3e3(0x1fe)]);}async[_0x439e03(0x22f)](_0x2210ff){const _0x2e5262=_0x439e03,{id:_0x60b847,role:_0x58487a}=_0x2210ff[_0x2e5262(0x1b4)];!this['freeQueueUsers'][_0x60b847]?this[_0x2e5262(0x1a0)][_0x60b847]=0x1:this[_0x2e5262(0x1a0)][_0x60b847]=this['freeQueueUsers'][_0x60b847]+0x1,console['log']('当前用户'+_0x60b847+_0x2e5262(0x234),this['freeQueueUsers'][_0x60b847]);}async[_0x439e03(0x1a1)](_0x1fd239){const _0x12ebef=_0x439e03,{id:_0x3ded8a,role:_0x4d1a10}=_0x1fd239[_0x12ebef(0x1b4)];if([_0x12ebef(0x1c0),_0x12ebef(0x1a2)]['includes'](_0x4d1a10))return!![];const {mjRateLimit:_0x165db9}=await this['getMjDefaultParams']();if(this[_0x12ebef(0x183)][_0x3ded8a]){const _0x28c422=this['rateLimits'][_0x3ded8a];if(_0x28c422>Date[_0x12ebef(0x216)]()){console[_0x12ebef(0x1cc)](_0x12ebef(0x19a)+_0x3ded8a+_0x12ebef(0x1fd));throw new common_1[(_0x12ebef(0x1d4))](_0x12ebef(0x197)+_0x165db9+_0x12ebef(0x1a4),common_1[_0x12ebef(0x213)][_0x12ebef(0x1fe)]);}else this['rateLimits'][_0x3ded8a]=Date[_0x12ebef(0x216)]()+Number(_0x165db9)*0x3e8;}else{const _0x3278b9=Date[_0x12ebef(0x216)]();this[_0x12ebef(0x183)][_0x3ded8a]=_0x3278b9+0x3e8*Number(_0x165db9);}}async['deductBalance'](_0x46d24b){const _0x2d517c=_0x439e03;await this[_0x2d517c(0x1ce)]['createQueryBuilder']()['update'](balance_entity_1['BalanceEntity'])['set']({'balance':()=>'balance\x20-\x201'})[_0x2d517c(0x1bc)](_0x2d517c(0x22c),{'userId':_0x46d24b[_0x2d517c(0x1b4)]['id']})[_0x2d517c(0x1d2)]();}async[_0x439e03(0x217)](){return 0x1;}};MjService=__decorate([(0x0,common_1['Injectable'])(),__param(0x0,(0x0,typeorm_2['InjectRepository'])(chatLog_entity_1[_0x439e03(0x1d3)])),__param(0x1,(0x0,typeorm_2[_0x439e03(0x1da)])(balance_entity_1['BalanceEntity'])),__metadata(_0x439e03(0x21e),[typeorm_1[_0x439e03(0x1dc)],typeorm_1[_0x439e03(0x1dc)],upload_service_1[_0x439e03(0x1c5)],chatLog_service_1[_0x439e03(0x232)],globalConfig_service_1['GlobalConfigService'],fanyi_service_1['FanyiService'],badwords_service_1[_0x439e03(0x215)]])],MjService),exports[_0x439e03(0x1b0)]=MjService;