mirror of
https://github.com/xiaoyiweb/YiAi.git
synced 2025-09-26 13:16:39 +08:00
1 line
29 KiB
JavaScript
1 line
29 KiB
JavaScript
'use strict';const _0x3857e2=_0xff4a;function _0x5757(){const _0x146861=['max','chatLogService','post','parse','find','mjGuildId','function','getMjDefaultParams','http://172.247.48.137:8000/mj/draw','\x20次开始查询\x20=>\x20当前查询结果:','mjVersion','checkRateLimit','../userBalance/balance.entity','replace','push','default','../badwords/badwords.service','error:\x20','变化图片任务异常中断\x20队列-1:\x20','当前提示词已经在任务队列中了、请勿重复提交。。。','https://discord.com/api/v9/interactions','开始查询绘画结果轮询','开始请求放大图片\x20队列+1:\x20','mjProxy','mjApplicationId','balance','extractContent','变换当前图片失败','url','Not','saveChatLog','BadwordsService','存入图片完成:\x20','InjectRepository','badwordsService','randomId:\x20','绘画失败','set','/messages?limit=50','mjDraw','rateLimits','有历史信息之间返回:\x20','由于速率限制、当前普通用户限制为','HttpStatus','get','292490rHFfam','sendSmInteractions','imagine','axios','deductBalance','历史记录中不存在当前图片、请确认您放大的图片是否存在','typeorm','当前图片已经放大过了、请勿重复放大!','variationId','pollForResult','绘制图片任务结束\x20队列-1:\x20','https://discord.com/api/v9/channels/','当前绘图任务满载、请排队等候、队列任务完成后即可开始您的任务...','baiduFanyiSecret','findCurrentVariationImgResult','__decorate','uploadService','网络连接失败,请稍后再试!','message','convertToEnglish','637554fbvRTG','mjNotSaveImg','chatLogEntity','orderId','queryMessageList','132xSDcAX','where','enlargeWorking','开始请求用户','变换图片任务结束\x20队列-1:\x20','getConfigs','checkAuth','object','checkFree','admin','../../common/utils','HttpException','../chatLog/chatLog.entity','metadata','您当前暂无MJ绘画余额!!!','mjSessionId','axios:\x20','userId\x20=\x20:userId','uploadFileFromUrl','放大图片任务异常中断\x20队列-1:\x20','balanceEntity','绘画任务开始','freeQueueUsers','查询期间出现错误:','../upload/upload.service','length','includes','__metadata','\x20队列+1:\x20','32727vwCvUl','本次比对的随机ID:\x20','match','秒请求一次、请合理使用!','stringify','log','绘画请求失败、当前使用人数过多、请稍后试试吧、排队中...','upscaleSingleImg','balance\x20-\x201','DeductionKey','@nestjs/typeorm','763166HferEa','绘制图片任务异常中断\x20队列-1:\x20','../fanyi/fanyi.service','user','2361360UxJhOI','本次放大图片的id:\x20','message_id','mjAuthorization','\x20次开始查询','mjChannelId','UploadService','fanyiService','prompt','pollForUpscaleResult','sleep','PAINT_TYPE','removeEmoji','findOne','prompt\x20-------->\x20\x20','查询绘制结果失败...','response','7djVdrF','MjService','BalanceEntity','map','发送放大指令成功','components','enlarge','绘画超时,请稍后再试!','now','substring','历史这些id已经被获取过了\x20不能拿了:\x20','放大custom_id:\x20','\x20次开始查询[变换图片]','draw','getClientIp','findCurrentPromptResult','本次绘图耗时:\x20','drawWorking','globalConfigService','sendDrawInteractions','1295640nlEBtu','BAD_REQUEST','GlobalConfigService','IsNull','63PdZNbt','417157ygOfmZ','ChatLogEntity','../chatLog/chatLog.service','开始请求变换图片\x20队列+1:\x20','放大图片任务结束\x20队列-1:\x20','Injectable','http://172.247.48.137:8000/mj/list?channel_id=','baiduFanyiAppId','发送绘画指令结果:\x20','Repository','pollForVariationResult','INTERNAL_SERVER_ERROR','历史记录中不存在当前图片、请确认您需要变换的图片是否存在','data','Like','floor','test','findCurrentEnlargeImgResult','使用的次数:','ChatLogService','mjRateLimit','queueCount','mjId','error','createQueryBuilder'];_0x5757=function(){return _0x146861;};return _0x5757();}(function(_0x4ee464,_0x4d4b70){const _0x98228=_0xff4a,_0x116286=_0x4ee464();while(!![]){try{const _0x3211bc=-parseInt(_0x98228(0x233))/0x1+-parseInt(_0x98228(0x205))/0x2+parseInt(_0x98228(0x1fa))/0x3*(parseInt(_0x98228(0x1dd))/0x4)+parseInt(_0x98228(0x22e))/0x5+parseInt(_0x98228(0x1d8))/0x6*(-parseInt(_0x98228(0x21a))/0x7)+parseInt(_0x98228(0x209))/0x8+-parseInt(_0x98228(0x232))/0x9*(-parseInt(_0x98228(0x1c4))/0xa);if(_0x3211bc===_0x4d4b70)break;else _0x116286['push'](_0x116286['shift']());}catch(_0x29f34d){_0x116286['push'](_0x116286['shift']());}}}(_0x5757,0x34417));var __decorate=this&&this[_0x3857e2(0x1d3)]||function(_0x4d21e,_0x533a9b,_0x5983f9,_0x1e5b96){var _0xa92183=arguments['length'],_0x4be5e0=_0xa92183<0x3?_0x533a9b:_0x1e5b96===null?_0x1e5b96=Object['getOwnPropertyDescriptor'](_0x533a9b,_0x5983f9):_0x1e5b96,_0x255407;if(typeof Reflect==='object'&&typeof Reflect['decorate']==='function')_0x4be5e0=Reflect['decorate'](_0x4d21e,_0x533a9b,_0x5983f9,_0x1e5b96);else{for(var _0x41b92a=_0x4d21e['length']-0x1;_0x41b92a>=0x0;_0x41b92a--)if(_0x255407=_0x4d21e[_0x41b92a])_0x4be5e0=(_0xa92183<0x3?_0x255407(_0x4be5e0):_0xa92183>0x3?_0x255407(_0x533a9b,_0x5983f9,_0x4be5e0):_0x255407(_0x533a9b,_0x5983f9))||_0x4be5e0;}return _0xa92183>0x3&&_0x4be5e0&&Object['defineProperty'](_0x533a9b,_0x5983f9,_0x4be5e0),_0x4be5e0;},__metadata=this&&this[_0x3857e2(0x1f8)]||function(_0xbcc6fd,_0x11f452){const _0x3dbcff=_0x3857e2;if(typeof Reflect===_0x3dbcff(0x1e4)&&typeof Reflect['metadata']===_0x3dbcff(0x19d))return Reflect[_0x3dbcff(0x1ea)](_0xbcc6fd,_0x11f452);},__param=this&&this['__param']||function(_0x36d26c,_0x175ad0){return function(_0x4a4e2b,_0x46354d){_0x175ad0(_0x4a4e2b,_0x46354d,_0x36d26c);};};function _0xff4a(_0x52d18a,_0x3ae3cb){const _0x575796=_0x5757();return _0xff4a=function(_0xff4ae7,_0xe03783){_0xff4ae7=_0xff4ae7-0x186;let _0xa3cca0=_0x575796[_0xff4ae7];return _0xa3cca0;},_0xff4a(_0x52d18a,_0x3ae3cb);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[_0x3857e2(0x21b)]=void 0x0;const globalConfig_service_1=require('../globalConfig/globalConfig.service'),upload_service_1=require(_0x3857e2(0x1f5)),common_1=require('@nestjs/common'),axios_1=require(_0x3857e2(0x1c7)),chatLog_service_1=require(_0x3857e2(0x235)),balance_constant_1=require('../../common/constants/balance.constant'),utils_1=require(_0x3857e2(0x1e7)),chatLog_entity_1=require(_0x3857e2(0x1e9)),typeorm_1=require(_0x3857e2(0x1ca)),typeorm_2=require(_0x3857e2(0x204)),balance_entity_1=require(_0x3857e2(0x1a3)),fanyi_service_1=require(_0x3857e2(0x207)),badwords_service_1=require(_0x3857e2(0x1a7));let MjService=class MjService{constructor(_0x387a30,_0x2a1f1a,_0x988d81,_0x17deea,_0x258133,_0x301b34,_0x1f9704){const _0x20277f=_0x3857e2;this[_0x20277f(0x1da)]=_0x387a30,this[_0x20277f(0x1f1)]=_0x2a1f1a,this[_0x20277f(0x1d4)]=_0x988d81,this['chatLogService']=_0x17deea,this[_0x20277f(0x22c)]=_0x258133,this['fanyiService']=_0x301b34,this[_0x20277f(0x1b9)]=_0x1f9704,this[_0x20277f(0x1bf)]={},this[_0x20277f(0x22b)]=[],this[_0x20277f(0x1df)]=[],this['queueCount']=0x0,this['freeQueueUsers']={};}async[_0x3857e2(0x1be)](_0x1b084f){const _0x3c4814=_0x3857e2,{jobId:_0x1052c4,prompt:_0x3d1ae6,startTime:_0x21e860,userId:_0x5adee0}=_0x1b084f;return console[_0x3c4814(0x1ff)](_0x3c4814(0x1f2),'mjservice'),await new Promise(_0x1e3e54=>setTimeout(_0x1e3e54,0x1388)),{'a':0x1,'b':0x2};}async[_0x3857e2(0x227)](_0x2b1129,_0x515a11){const _0x357dc2=_0x3857e2;await this[_0x357dc2(0x1e3)](_0x515a11),await this['badwordsService']['checkBadWords'](_0x2b1129[_0x357dc2(0x211)],_0x515a11[_0x357dc2(0x208)]['id']);const _0x392f16=_0x2b1129[_0x357dc2(0x211)];let _0x4d40d4=_0x2b1129['prompt'];const {baiduFanyiAppId:_0x1cb888,baiduFanyiSecret:_0x4f7809}=await this[_0x357dc2(0x22c)]['getConfigs']([_0x357dc2(0x23a),_0x357dc2(0x1d1)]);_0x1cb888&&_0x4f7809&&(_0x4d40d4=await this[_0x357dc2(0x210)][_0x357dc2(0x1d7)](_0x392f16));const _0x371eb7='['+(0x0,utils_1['createRandomUid'])()+']',_0x50530e=_0x371eb7+'\x20'+_0x4d40d4;console[_0x357dc2(0x1ff)](_0x357dc2(0x1ba),_0x371eb7),console[_0x357dc2(0x1ff)](_0x357dc2(0x217),_0x50530e);const _0x3b1341=this[_0x357dc2(0x22b)][_0x357dc2(0x19b)](_0x338242=>_0x338242['includes'](_0x2b1129[_0x357dc2(0x211)]));if(_0x3b1341)throw new common_1[(_0x357dc2(0x1e8))](_0x357dc2(0x1aa),common_1[_0x357dc2(0x1c2)][_0x357dc2(0x22f)]);if(this[_0x357dc2(0x193)]>=0x3)throw new common_1['HttpException'](_0x357dc2(0x1d0),common_1[_0x357dc2(0x1c2)]['BAD_REQUEST']);await this[_0x357dc2(0x1a2)](_0x515a11),this[_0x357dc2(0x193)]++,console[_0x357dc2(0x1ff)](_0x357dc2(0x1e0)+_0x515a11[_0x357dc2(0x208)]['id']+_0x357dc2(0x1f9),this[_0x357dc2(0x193)]);try{const _0x5816f4=await this[_0x357dc2(0x1da)][_0x357dc2(0x19b)]({'where':{'prompt':(0x0,typeorm_1[_0x357dc2(0x18c)])('%'+_0x50530e+'%')}}),_0x40f5db=_0x5816f4[_0x357dc2(0x21d)](_0x22935d=>_0x22935d[_0x357dc2(0x20b)]);this[_0x357dc2(0x22b)][_0x357dc2(0x1a5)](_0x50530e);let _0x3dfe38;const _0x386064=await this['sendDrawInteractions'](_0x50530e,_0x40f5db,_0x371eb7);_0x386064?(console[_0x357dc2(0x1ff)]('历史中存在当前图片、直接获取!'),_0x3dfe38=_0x386064):_0x3dfe38=await this['pollForResult'](_0x50530e,_0x40f5db,_0x371eb7);this[_0x357dc2(0x193)]--,this[_0x357dc2(0x193)]<0x0&&(this[_0x357dc2(0x193)]=0x0),console['log'](_0x357dc2(0x1ce),this[_0x357dc2(0x193)]);const {id:_0x58e140,content:_0x76d83f,channel_id:_0x233262,attachments:attachments=[],timestamp:_0x199887}=_0x3dfe38;if(!attachments[_0x357dc2(0x1f6)]||!attachments[0x0]['url'])throw new common_1['HttpException'](_0x357dc2(0x1bb),common_1[_0x357dc2(0x1c2)][_0x357dc2(0x22f)]);const {filename:_0x2734df,url:_0x57386f,width:_0xca3388,height:_0x29afb7,size:_0x47a901}=attachments[0x0];console[_0x357dc2(0x1ff)]('拿到了远程地址:\x20',_0x57386f);const _0x54d467=this[_0x357dc2(0x22c)]['getConfigs'](['mjNotSaveImg']);let _0x278886='';(!Number(_0x54d467)||Number(_0x54d467)===0x0)&&(_0x278886=await this[_0x357dc2(0x1d4)][_0x357dc2(0x1ef)]({'filename':_0x2734df,'url':_0x57386f}),console[_0x357dc2(0x1ff)]('存入图片完成:\x20',_0x278886));const _0x11ef7c={'curIp':(0x0,utils_1[_0x357dc2(0x228)])(_0x515a11),'userId':_0x515a11['user']['id'],'type':balance_constant_1[_0x357dc2(0x203)][_0x357dc2(0x214)],'prompt':_0x50530e,'answer':_0x278886,'model':'mj','extend':this[_0x357dc2(0x215)](JSON[_0x357dc2(0x1fe)](_0x3dfe38)),'message_id':_0x58e140,'variationId':_0x58e140,'upscaleId':_0x58e140,'group':0x1,'isSaveImg':!Number(_0x54d467)||Number(_0x54d467)===0x0,'fileInfo':JSON['stringify']({'width':_0xca3388,'height':_0x29afb7,'size':_0x47a901,'filename':_0x2734df,'cosUrl':_0x278886})};return await this['chatLogService'][_0x357dc2(0x1b5)](_0x11ef7c),await this['deductBalance'](_0x515a11),this[_0x357dc2(0x22b)]=this[_0x357dc2(0x22b)]['filter'](_0x331b46=>_0x331b46!==_0x2b1129[_0x357dc2(0x211)]),_0x278886;}catch(_0x545723){this[_0x357dc2(0x193)]--,this['queueCount']<0x0&&(this[_0x357dc2(0x193)]=0x0),console[_0x357dc2(0x1ff)](_0x357dc2(0x206),this[_0x357dc2(0x193)]),this[_0x357dc2(0x22b)]=this[_0x357dc2(0x22b)]['filter'](_0x2782c3=>_0x2782c3!==_0x2b1129['prompt']);throw new common_1[(_0x357dc2(0x1e8))](_0x545723[_0x357dc2(0x219)],common_1[_0x357dc2(0x1c2)]['BAD_REQUEST']);}}async[_0x3857e2(0x201)](_0x4c5f7f,_0x2d7b47){const _0x499340=_0x3857e2;if(this['queueCount']>=0x3)throw new common_1[(_0x499340(0x1e8))](_0x499340(0x1d0),common_1['HttpStatus'][_0x499340(0x22f)]);this['queueCount']++,console[_0x499340(0x1ff)]('用户'+_0x2d7b47[_0x499340(0x208)]['id']+_0x499340(0x1ad),this['queueCount']);const {message_id:_0x33818d,orderId:_0x59ef8d}=_0x4c5f7f;try{const _0xe7555c=await this['chatLogEntity'][_0x499340(0x216)]({'where':{'message_id':_0x33818d}});if(!_0xe7555c)throw new common_1[(_0x499340(0x1e8))](_0x499340(0x1c9),common_1['HttpStatus'][_0x499340(0x22f)]);const _0x2abb36=await this['chatLogEntity'][_0x499340(0x216)]({'where':{'upscaleId':_0x33818d,'action':'enlarge','orderId':_0x59ef8d}});if(_0x2abb36)throw new common_1[(_0x499340(0x1e8))](_0x499340(0x1cb),common_1[_0x499340(0x1c2)][_0x499340(0x22f)]);const {prompt:_0x418b96,extend:_0x2374f0}=_0xe7555c;let _0x5b7b13=null;try{_0x5b7b13=JSON[_0x499340(0x19a)](_0x2374f0);}catch(_0xb914aa){_0x5b7b13=[];}const {components:components=[]}=_0x5b7b13;if(!components[_0x499340(0x1f6)])throw new common_1[(_0x499340(0x1e8))]('当前图片没有绘画信息、无法放大!',common_1[_0x499340(0x1c2)]['BAD_REQUEST']);const _0x3c3c1e=components[0x0][_0x499340(0x21f)][_0x59ef8d-0x1],{custom_id:_0x59d39d}=_0x3c3c1e;console[_0x499340(0x1ff)](_0x499340(0x225),_0x59d39d);const _0x1f175a={'message_id':_0x33818d,'custom_id':_0x59d39d,'prompt':_0x418b96,'orderId':_0x59ef8d};await this['sendSmInteractions'](_0x1f175a),console['log'](_0x499340(0x21e));const _0x4fc788=await this[_0x499340(0x1da)][_0x499340(0x19b)]({'where':{'prompt':(0x0,typeorm_1[_0x499340(0x18c)])('%'+_0x418b96+'%')}}),_0x1b5d4b=_0x4fc788[_0x499340(0x21d)](_0x126c79=>_0x126c79[_0x499340(0x20b)]);console['log'](_0x499340(0x224),_0x1b5d4b);const _0x1104bb=await this['pollForUpscaleResult'](_0x1f175a,_0x1b5d4b);this['queueCount']--,this['queueCount']<0x0&&(this['queueCount']=0x0),console['log'](_0x499340(0x237),this[_0x499340(0x193)]);const {id:_0x545d52,content:_0x59c71f,channel_id:_0x2d6296,attachments:attachments=[],timestamp:_0x31bd1d}=_0x1104bb;if(!attachments['length']||!attachments[0x0][_0x499340(0x1b3)])throw new common_1['HttpException']('放大当前图片失败',common_1[_0x499340(0x1c2)][_0x499340(0x22f)]);const {filename:_0x1f16a5,url:_0x561587,width:_0x4af5cc,height:_0xc5d7d3,size:_0x14af8e}=attachments[0x0],_0x101455=this['globalConfigService'][_0x499340(0x1e2)]([_0x499340(0x1d9)]);let _0x2fe834='';(!Number(_0x101455)||Number(_0x101455)===0x0)&&(_0x2fe834=await this[_0x499340(0x1d4)][_0x499340(0x1ef)]({'filename':_0x1f16a5,'url':_0x561587}),console[_0x499340(0x1ff)](_0x499340(0x1b7),_0x2fe834));const _0x497d44={'curIp':(0x0,utils_1['getClientIp'])(_0x2d7b47),'userId':_0x2d7b47[_0x499340(0x208)]['id'],'type':balance_constant_1['DeductionKey'][_0x499340(0x214)],'prompt':_0x418b96,'answer':_0x2fe834,'model':'mj','extend':this[_0x499340(0x215)](JSON[_0x499340(0x1fe)](_0x1104bb)),'message_id':_0x33818d,'upscaleId':_0x545d52,'variationId':_0x545d52,'action':_0x499340(0x220),'orderId':_0x1f175a[_0x499340(0x1db)],'isSaveImg':!Number(_0x101455)||Number(_0x101455)===0x0,'fileInfo':JSON[_0x499340(0x1fe)]({'width':_0x4af5cc,'height':_0xc5d7d3,'size':_0x14af8e,'filename':_0x1f16a5,'cosUrl':_0x2fe834})};return await this[_0x499340(0x198)][_0x499340(0x1b5)](_0x497d44),_0x2fe834;}catch(_0x415fe3){console[_0x499340(0x1ff)](_0x499340(0x1a8),_0x415fe3),this[_0x499340(0x193)]--,this[_0x499340(0x193)]<0x0&&(this[_0x499340(0x193)]=0x0),console['log'](_0x499340(0x1f0),this[_0x499340(0x193)]);throw new common_1[(_0x499340(0x1e8))](_0x415fe3[_0x499340(0x219)],common_1['HttpStatus'][_0x499340(0x22f)]);}}async['variationSingleImg'](_0x492a0b,_0x276f09){const _0x283d22=_0x3857e2;if(this[_0x283d22(0x193)]>=0x3)throw new common_1[(_0x283d22(0x1e8))](_0x283d22(0x1d0),common_1['HttpStatus'][_0x283d22(0x22f)]);await this[_0x283d22(0x1e3)](_0x276f09),await this['checkRateLimit'](_0x276f09),this['queueCount']++,console[_0x283d22(0x1ff)]('用户'+_0x276f09['user']['id']+_0x283d22(0x236),this[_0x283d22(0x193)]);const {message_id:_0x5a30b3,orderId:_0x332676}=_0x492a0b;try{const _0x227575=await this['chatLogEntity'][_0x283d22(0x216)]({'where':{'message_id':_0x5a30b3}});if(!_0x227575)throw new common_1[(_0x283d22(0x1e8))](_0x283d22(0x18a),common_1['HttpStatus'][_0x283d22(0x22f)]);const {prompt:_0x2550b7,extend:_0x3929c9}=_0x227575;let _0x79c4be=null;try{_0x79c4be=JSON[_0x283d22(0x19a)](_0x3929c9);}catch(_0x4f844a){_0x79c4be=[];}const {components:components=[]}=_0x79c4be;if(!components['length'])throw new common_1[(_0x283d22(0x1e8))]('当前图片没有绘画信息、无法变体!',common_1[_0x283d22(0x1c2)][_0x283d22(0x22f)]);const _0x585cc9=components[0x1][_0x283d22(0x21f)][_0x332676-0x1],{custom_id:_0x4d9307}=_0x585cc9,_0x3e1146=await this[_0x283d22(0x1da)][_0x283d22(0x19b)]({'where':{'variationId':(0x0,typeorm_1[_0x283d22(0x1b4)])((0x0,typeorm_1[_0x283d22(0x231)])()),'prompt':(0x0,typeorm_1['Like'])('%'+_0x2550b7+'%')}}),_0x260897=_0x3e1146[_0x283d22(0x21d)](_0x3a6aca=>_0x3a6aca[_0x283d22(0x1cc)]),_0x2152b0={'message_id':_0x5a30b3,'custom_id':_0x4d9307,'prompt':_0x2550b7,'orderId':_0x332676};await this[_0x283d22(0x1c5)](_0x2152b0);const _0x67021f=await this[_0x283d22(0x188)](_0x2152b0,_0x260897);this[_0x283d22(0x193)]--,this[_0x283d22(0x193)]<0x0&&(this[_0x283d22(0x193)]=0x0),console['log'](_0x283d22(0x1e1),this[_0x283d22(0x193)]);const {id:_0x53df1c,content:_0xc001cc,channel_id:_0x195a50,attachments:attachments=[],timestamp:_0x104bcd}=_0x67021f;if(!attachments[_0x283d22(0x1f6)]||!attachments[0x0]['url'])throw new common_1[(_0x283d22(0x1e8))](_0x283d22(0x1b2),common_1[_0x283d22(0x1c2)][_0x283d22(0x22f)]);const {filename:_0x162bd1,url:_0x11635c,width:_0x4c40ab,height:_0x1e7a60,size:_0x54ec9d}=attachments[0x0],_0x36a782=this[_0x283d22(0x22c)][_0x283d22(0x1e2)]([_0x283d22(0x1d9)]);let _0x1aaa3f='';(!Number(_0x36a782)||Number(_0x36a782)===0x0)&&(_0x1aaa3f=await this[_0x283d22(0x1d4)][_0x283d22(0x1ef)]({'filename':_0x162bd1,'url':_0x11635c}),console[_0x283d22(0x1ff)](_0x283d22(0x1b7),_0x1aaa3f));const _0x352ff5={'curIp':(0x0,utils_1[_0x283d22(0x228)])(_0x276f09),'userId':_0x276f09[_0x283d22(0x208)]['id'],'type':balance_constant_1[_0x283d22(0x203)][_0x283d22(0x214)],'prompt':_0x2550b7,'answer':_0x1aaa3f,'model':'mj','group':0x1,'extend':this[_0x283d22(0x215)](JSON[_0x283d22(0x1fe)](_0x67021f)),'message_id':_0x53df1c,'upscaleId':_0x53df1c,'variationId':_0x53df1c,'action':_0x283d22(0x220),'orderId':_0x2152b0[_0x283d22(0x1db)],'isSaveImg':!Number(_0x36a782)||Number(_0x36a782)===0x0,'fileInfo':JSON[_0x283d22(0x1fe)]({'width':_0x4c40ab,'height':_0x1e7a60,'size':_0x54ec9d,'filename':_0x162bd1,'cosUrl':_0x1aaa3f})};return await this[_0x283d22(0x198)][_0x283d22(0x1b5)](_0x352ff5),_0x1aaa3f;}catch(_0x38c247){console[_0x283d22(0x1ff)](_0x283d22(0x1a8),_0x38c247),this[_0x283d22(0x193)]--,this[_0x283d22(0x193)]<0x0&&(this[_0x283d22(0x193)]=0x0),console[_0x283d22(0x1ff)](_0x283d22(0x1a9),this[_0x283d22(0x193)]);throw new common_1['HttpException'](_0x38c247[_0x283d22(0x219)],common_1[_0x283d22(0x1c2)][_0x283d22(0x22f)]);}}async[_0x3857e2(0x1c5)](_0x535df7){const _0x2e5e3c=_0x3857e2,{message_id:_0x13ae30,custom_id:_0x56d7a1}=_0x535df7,{application_id:_0x51e688,guild_id:_0x42c117,channel_id:_0x3d080a,session_id:_0x3d01d4,version:_0x3b2bca,id:_0x4ab284,authorization:_0x4494f7,mjProxy:_0x31c5c8}=await this[_0x2e5e3c(0x19e)](),_0x478e54=_0x31c5c8==0x1?'http://172.247.48.137:8000/mj/draw':_0x2e5e3c(0x1ab),_0xd0cf0a={'authorization':_0x4494f7},_0x3afa61={'type':0x3,'guild_id':_0x42c117,'channel_id':_0x3d080a,'message_flags':0x0,'message_id':_0x13ae30,'application_id':_0x51e688,'session_id':_0x3d01d4,'data':{'component_type':0x2,'custom_id':_0x56d7a1}};try{await axios_1[_0x2e5e3c(0x1a6)]['post'](_0x478e54,_0x3afa61,{'headers':_0xd0cf0a}),console[_0x2e5e3c(0x1ff)]('绘图指令完成');}catch(_0x375577){console['log'](_0x2e5e3c(0x1a8),_0x375577);throw new common_1[(_0x2e5e3c(0x1e8))]('放大单张图片请求失败...',common_1['HttpStatus']['BAD_REQUEST']);}}async[_0x3857e2(0x212)](_0x4bdedd,_0x5dee1b){const _0x171edd=_0x3857e2,{message_id:_0x395f9a,custom_id:_0x533650,prompt:_0x1aa239,orderId:_0x9e57a6}=_0x4bdedd;let _0x1aa093=null,_0x308416=0x0;while(!_0x1aa093&&_0x308416<0xa){try{const _0x207046=Date[_0x171edd(0x222)](),_0x16994c=await this[_0x171edd(0x1dc)]();console[_0x171edd(0x1ff)]('第\x20'+(_0x308416+0x1)+_0x171edd(0x1a0)+_0x16994c['length']);_0x16994c&&_0x16994c['length']&&(_0x1aa093=await this[_0x171edd(0x18f)](_0x16994c,_0x4bdedd,_0x5dee1b));const _0x4523e3=Date[_0x171edd(0x222)]()-_0x207046,_0x3df1d5=0xbb8;await this[_0x171edd(0x213)](Math[_0x171edd(0x197)](_0x3df1d5-_0x4523e3,0x0)),_0x308416++;}catch(_0x5a174b){console[_0x171edd(0x195)]('查询期间出现错误:'+_0x5a174b[_0x171edd(0x1d6)]);}}return _0x1aa093;}async[_0x3857e2(0x188)](_0x386690,_0x1bc1b9){const _0x2c3097=_0x3857e2,{message_id:_0x1e6b80,custom_id:_0x18344c,prompt:_0x35ef06,orderId:_0x3daa8c}=_0x386690;console[_0x2c3097(0x1ff)]('开始轮询单张变换图片结果');let _0x27ce0f=null,_0x34b4b2=0x0;while(!_0x27ce0f&&_0x34b4b2<0xa){try{console[_0x2c3097(0x1ff)]('第\x20'+(_0x34b4b2+0x1)+_0x2c3097(0x226));const _0x3bb5df=Date[_0x2c3097(0x222)](),_0xaeaa77=await this[_0x2c3097(0x1dc)]();_0xaeaa77&&_0xaeaa77['length']&&(_0x27ce0f=await this[_0x2c3097(0x1d2)](_0xaeaa77,_0x386690,_0x1bc1b9));const _0x3ce61d=Date[_0x2c3097(0x222)]()-_0x3bb5df,_0x2969f7=0x1f40;await this[_0x2c3097(0x213)](Math[_0x2c3097(0x197)](_0x2969f7-_0x3ce61d,0x0)),_0x34b4b2++;}catch(_0x4e2e21){console[_0x2c3097(0x195)](_0x2c3097(0x1f4)+_0x4e2e21[_0x2c3097(0x1d6)]);}}if(!_0x27ce0f)throw new common_1['HttpException']('变换当前图片超时!',common_1[_0x2c3097(0x1c2)][_0x2c3097(0x22f)]);return _0x27ce0f;}async['findCurrentEnlargeImgResult'](_0x299200,_0x5103ce,_0x3481df){const _0x5c036a=_0x3857e2,{message_id:_0x337fd1,custom_id:_0x4a6edd,prompt:_0xb61818,orderId:_0x4d159d}=_0x5103ce,_0x1fb0ec=_0xb61818[_0x5c036a(0x223)](0x0,0xc);console[_0x5c036a(0x1ff)](_0x5c036a(0x20a),_0x1fb0ec);const _0x1dbe8e=_0x299200['find'](_0x4ad0ec=>{const _0x108b5c=_0x5c036a,{content:_0x3e7243}=_0x4ad0ec;if(!this['extractContent'](_0x3e7243))return![];const {prompt:_0x5d294a,order:_0x301841}=this[_0x108b5c(0x1b1)](_0x3e7243);return _0x5d294a[_0x108b5c(0x1f7)](_0x1fb0ec)&&_0x5103ce[_0x108b5c(0x1db)]===_0x301841&&!_0x3481df[_0x108b5c(0x1f7)](_0x4ad0ec['id']);});return _0x1dbe8e;}async[_0x3857e2(0x1d2)](_0x3f626b,_0x59743b,_0x10738e){const _0x4af415=_0x3857e2,{message_id:_0x26773b,custom_id:_0xe50fd8,prompt:_0x821482,orderId:_0x39c88f}=_0x59743b,_0x4c9355=_0x821482['substring'](0x0,0xc),_0x3ad86d=_0x3f626b[_0x4af415(0x19b)](_0x7a81de=>{const _0x1eee04=_0x4af415,{content:_0xa41726}=_0x7a81de,_0x3516fa=_0xa41726['match'](/\*\*(.+?)\*\*/),_0x1f29ed=_0x3516fa?_0x3516fa[0x1]:'';if(!_0x1f29ed)return![];return _0x1f29ed[_0x1eee04(0x1f7)](_0x4c9355)&&!_0x10738e['includes'](_0x7a81de['id']);});return _0x3ad86d;}async[_0x3857e2(0x22d)](_0x3aed77,_0x55fa26,_0x240e30){const _0x2aeec1=_0x3857e2,_0x126cb6=await this[_0x2aeec1(0x1dc)](),_0x5889f0=await this['findCurrentPromptResult'](_0x126cb6,_0x240e30,_0x55fa26);if(_0x5889f0)return console['log'](_0x2aeec1(0x1c0),_0x5889f0),_0x5889f0;const {application_id:_0x1654bc,guild_id:_0x5a85b2,channel_id:_0x3f2f65,session_id:_0x15ea75,version:_0x4fe1cb,id:_0x31c9a3,authorization:_0x493fdd,mjProxy:_0x2358d0}=await this[_0x2aeec1(0x19e)](),_0x553983={'type':0x2,'application_id':_0x1654bc,'guild_id':_0x5a85b2,'channel_id':_0x3f2f65,'session_id':_0x15ea75,'data':{'version':_0x4fe1cb,'id':_0x31c9a3,'name':_0x2aeec1(0x1c6),'type':0x1,'options':[{'type':0x3,'name':'prompt','value':_0x3aed77}],'attachments':[]}};try{const _0x5b8c63=_0x2358d0==0x1?_0x2aeec1(0x19f):_0x2aeec1(0x1ab),_0x50660d={'authorization':_0x493fdd},_0x3994e1=await axios_1[_0x2aeec1(0x1a6)][_0x2aeec1(0x199)](_0x5b8c63,_0x553983,{'headers':_0x50660d});return console['log'](_0x2aeec1(0x186),_0x3994e1[_0x2aeec1(0x18b)]),![];}catch(_0x1a65ad){console[_0x2aeec1(0x1ff)](_0x2aeec1(0x1ed),_0x1a65ad);throw new common_1['HttpException'](_0x2aeec1(0x200),common_1['HttpStatus'][_0x2aeec1(0x22f)]);}}async[_0x3857e2(0x1cd)](_0x1c7ccd,_0x56b0bc,_0xc174fc){const _0x292527=_0x3857e2;console[_0x292527(0x1ff)](_0x292527(0x1ac));const _0x5303d3=Date['now']();try{const _0x1c2b96=0xd,_0x3bd3eb=0x2ee0,_0x3bb6c1=0x1388,_0x382153=0x3c*0x3e8;let _0x122049=0x0,_0xf65f08=![],_0x47cdca=null;while(!_0x47cdca&&_0x122049<_0x1c2b96){console['log']('第\x20'+(_0x122049+0x1)+_0x292527(0x20d));Date[_0x292527(0x222)]()-_0x5303d3>=_0x382153&&(_0xf65f08=!![]);await this[_0x292527(0x213)](_0xf65f08?_0x3bb6c1:_0x3bd3eb);const _0x2dcc1f=await this['queryMessageList']();_0x47cdca=await this[_0x292527(0x229)](_0x2dcc1f,_0xc174fc,_0x56b0bc),_0x122049++;}if(!_0x47cdca)throw new common_1['HttpException'](_0x292527(0x221),common_1[_0x292527(0x1c2)][_0x292527(0x22f)]);const _0x681add=Date[_0x292527(0x222)]();return console[_0x292527(0x1ff)](_0x292527(0x22a)+Math[_0x292527(0x18d)]((_0x681add-_0x5303d3)/0x3e8)+'\x20S'),_0x47cdca;}catch(_0x28554b){console['error'](_0x28554b[_0x292527(0x1d6)]);throw new common_1[(_0x292527(0x1e8))](_0x292527(0x1d5),common_1['HttpStatus'][_0x292527(0x189)]);}}async[_0x3857e2(0x229)](_0x17650e,_0x1708e9,_0x4145c8){const _0x2ac38e=_0x3857e2;if(!_0x17650e||!_0x17650e['length'])return;console[_0x2ac38e(0x1ff)](_0x2ac38e(0x1fb),_0x1708e9);const _0x11dc37=_0x17650e['find'](_0x3af95b=>{const _0x2d8452=_0x2ac38e,{attachments:attachments=[],content:_0x28493d,edited_timestamp:_0x4181f2}=_0x3af95b;return _0x28493d[_0x2d8452(0x1f7)](_0x1708e9)&&attachments[_0x2d8452(0x1f6)]>0x0&&!_0x4181f2&&!_0x4145c8['includes'](_0x3af95b['id']);});return _0x11dc37||null;}async[_0x3857e2(0x1dc)](){const _0x3e96ea=_0x3857e2;try{const {application_id:_0xd1531d,guild_id:_0x5d7228,channel_id:_0x1fa615,session_id:_0xab51a6,version:_0x3b79af,id:_0x13aa32,authorization:_0x1690f0,mjProxy:_0xdca3dc}=await this['getMjDefaultParams'](),_0x38e641=_0xdca3dc==0x1?_0x3e96ea(0x239)+_0x1fa615:_0x3e96ea(0x1cf)+_0x1fa615+_0x3e96ea(0x1bd),_0x5162db={'authorization':_0x1690f0},_0x12e643=await axios_1[_0x3e96ea(0x1a6)][_0x3e96ea(0x1c3)](_0x38e641,{'headers':_0x5162db});return _0x12e643['data'];}catch(_0x1e5aab){console[_0x3e96ea(0x1ff)]('axios\x20get:\x20',_0x1e5aab);throw new common_1[(_0x3e96ea(0x1e8))](_0x3e96ea(0x218),common_1[_0x3e96ea(0x1c2)]['BAD_REQUEST']);}}async[_0x3857e2(0x213)](_0x2f2294){return new Promise(_0x19d737=>setTimeout(_0x19d737,_0x2f2294));}[_0x3857e2(0x1b1)](_0x1b37f8){const _0xe9360a=_0x3857e2,_0x1951b1=_0x1b37f8[_0xe9360a(0x1fc)](/\*\*(.+?)\*\*/),_0x417c28=_0x1b37f8['match'](/- Image #(\d+)/);if(!_0x1951b1||!_0x417c28)return null;const _0x275d3d=_0x1951b1[0x1],_0x8b448b=parseInt(_0x417c28[0x1]);return{'prompt':_0x275d3d,'order':_0x8b448b};}async[_0x3857e2(0x19e)](){const _0x2cc01e=_0x3857e2,_0x438e98=await this[_0x2cc01e(0x22c)][_0x2cc01e(0x1e2)]([_0x2cc01e(0x194),_0x2cc01e(0x1af),_0x2cc01e(0x19c),_0x2cc01e(0x20e),_0x2cc01e(0x1ec),'mjVersion',_0x2cc01e(0x20c),_0x2cc01e(0x192),_0x2cc01e(0x1ae)]),_0xeb9b78={'application_id':_0x438e98[_0x2cc01e(0x1af)],'guild_id':_0x438e98[_0x2cc01e(0x19c)],'channel_id':_0x438e98['mjChannelId'],'session_id':_0x438e98[_0x2cc01e(0x1ec)],'version':_0x438e98[_0x2cc01e(0x1a1)],'id':_0x438e98[_0x2cc01e(0x194)],'authorization':_0x438e98['mjAuthorization'],'mjRateLimit':_0x438e98[_0x2cc01e(0x192)],'mjProxy':_0x438e98[_0x2cc01e(0x1ae)]||0x0};return _0xeb9b78;}[_0x3857e2(0x215)](_0x2d1cef){const _0x569971=_0x3857e2,_0x51bd7f=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return _0x2d1cef[_0x569971(0x1a4)](_0x51bd7f,'');}async['checkAuth'](_0x3265c2){const _0x1ad6a3=_0x3857e2,_0x394540=await this[_0x1ad6a3(0x1f1)][_0x1ad6a3(0x216)]({'where':{'userId':_0x3265c2[_0x1ad6a3(0x208)]['id']}}),{id:_0x57e9dd,balance:_0x3cc372}=_0x394540;if(!_0x3cc372||(_0x394540===null||_0x394540===void 0x0?void 0x0:_0x394540[_0x1ad6a3(0x1b0)])<0x1)throw new common_1[(_0x1ad6a3(0x1e8))](_0x1ad6a3(0x1eb),common_1[_0x1ad6a3(0x1c2)][_0x1ad6a3(0x22f)]);}async[_0x3857e2(0x1e5)](_0x448399){const _0x7c29f7=_0x3857e2,{id:_0x45e0f8,role:_0x4fcc54}=_0x448399['user'];!this['freeQueueUsers'][_0x45e0f8]?this[_0x7c29f7(0x1f3)][_0x45e0f8]=0x1:this[_0x7c29f7(0x1f3)][_0x45e0f8]=this[_0x7c29f7(0x1f3)][_0x45e0f8]+0x1,console[_0x7c29f7(0x1ff)]('当前用户'+_0x45e0f8+_0x7c29f7(0x190),this[_0x7c29f7(0x1f3)][_0x45e0f8]);}async[_0x3857e2(0x1a2)](_0x8b24e){const _0x35daae=_0x3857e2,{id:_0x4e5924,role:_0x41db2f}=_0x8b24e[_0x35daae(0x208)];if([_0x35daae(0x1e6),'super'][_0x35daae(0x1f7)](_0x41db2f))return!![];const {mjRateLimit:_0x15ee79}=await this[_0x35daae(0x19e)]();if(this['rateLimits'][_0x4e5924]){const _0x33f421=this[_0x35daae(0x1bf)][_0x4e5924];if(_0x33f421>Date[_0x35daae(0x222)]()){console[_0x35daae(0x1ff)]('当前用户\x20'+_0x4e5924+'\x20请求过于频繁!');throw new common_1['HttpException'](_0x35daae(0x1c1)+_0x15ee79+_0x35daae(0x1fd),common_1['HttpStatus'][_0x35daae(0x22f)]);}else this['rateLimits'][_0x4e5924]=Date['now']()+Number(_0x15ee79)*0x3e8;}else{const _0xe796b8=Date[_0x35daae(0x222)]();this[_0x35daae(0x1bf)][_0x4e5924]=_0xe796b8+0x3e8*Number(_0x15ee79);}}async[_0x3857e2(0x1c8)](_0x2b027f){const _0x4beba7=_0x3857e2;await this[_0x4beba7(0x1f1)][_0x4beba7(0x196)]()['update'](balance_entity_1[_0x4beba7(0x21c)])[_0x4beba7(0x1bc)]({'balance':()=>_0x4beba7(0x202)})[_0x4beba7(0x1de)](_0x4beba7(0x1ee),{'userId':_0x2b027f[_0x4beba7(0x208)]['id']})['execute']();}async[_0x3857e2(0x18e)](){return 0x1;}};MjService=__decorate([(0x0,common_1[_0x3857e2(0x238)])(),__param(0x0,(0x0,typeorm_2[_0x3857e2(0x1b8)])(chatLog_entity_1[_0x3857e2(0x234)])),__param(0x1,(0x0,typeorm_2[_0x3857e2(0x1b8)])(balance_entity_1['BalanceEntity'])),__metadata('design:paramtypes',[typeorm_1[_0x3857e2(0x187)],typeorm_1['Repository'],upload_service_1[_0x3857e2(0x20f)],chatLog_service_1[_0x3857e2(0x191)],globalConfig_service_1[_0x3857e2(0x230)],fanyi_service_1['FanyiService'],badwords_service_1[_0x3857e2(0x1b6)]])],MjService),exports[_0x3857e2(0x21b)]=MjService; |