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

1 line
11 KiB
JavaScript

'use strict';const _0x1d51e5=_0x3632;(function(_0x311301,_0xd4a254){const _0x22325c=_0x3632,_0x3dd54e=_0x311301();while(!![]){try{const _0x3a5283=parseInt(_0x22325c(0x1a2))/0x1*(-parseInt(_0x22325c(0x188))/0x2)+parseInt(_0x22325c(0x18c))/0x3+-parseInt(_0x22325c(0x1a1))/0x4*(-parseInt(_0x22325c(0x174))/0x5)+parseInt(_0x22325c(0x158))/0x6*(-parseInt(_0x22325c(0x1b0))/0x7)+-parseInt(_0x22325c(0x19b))/0x8*(parseInt(_0x22325c(0x1be))/0x9)+parseInt(_0x22325c(0x1b5))/0xa+parseInt(_0x22325c(0x16d))/0xb;if(_0x3a5283===_0xd4a254)break;else _0x3dd54e['push'](_0x3dd54e['shift']());}catch(_0x438645){_0x3dd54e['push'](_0x3dd54e['shift']());}}}(_0x5e58,0x601e5));function _0x3632(_0x547c05,_0x31cc43){const _0x5e5865=_0x5e58();return _0x3632=function(_0x36321a,_0x18da4e){_0x36321a=_0x36321a-0x158;let _0x32486a=_0x5e5865[_0x36321a];return _0x32486a;},_0x3632(_0x547c05,_0x31cc43);}var __decorate=this&&this['__decorate']||function(_0x419d6d,_0x283917,_0x19bfe1,_0x3e6e7a){const _0x7430ca=_0x3632;var _0x389e1b=arguments[_0x7430ca(0x176)],_0x4ebe8b=_0x389e1b<0x3?_0x283917:_0x3e6e7a===null?_0x3e6e7a=Object['getOwnPropertyDescriptor'](_0x283917,_0x19bfe1):_0x3e6e7a,_0x4a63de;if(typeof Reflect===_0x7430ca(0x169)&&typeof Reflect[_0x7430ca(0x184)]===_0x7430ca(0x166))_0x4ebe8b=Reflect['decorate'](_0x419d6d,_0x283917,_0x19bfe1,_0x3e6e7a);else{for(var _0x523450=_0x419d6d[_0x7430ca(0x176)]-0x1;_0x523450>=0x0;_0x523450--)if(_0x4a63de=_0x419d6d[_0x523450])_0x4ebe8b=(_0x389e1b<0x3?_0x4a63de(_0x4ebe8b):_0x389e1b>0x3?_0x4a63de(_0x283917,_0x19bfe1,_0x4ebe8b):_0x4a63de(_0x283917,_0x19bfe1))||_0x4ebe8b;}return _0x389e1b>0x3&&_0x4ebe8b&&Object[_0x7430ca(0x1ad)](_0x283917,_0x19bfe1,_0x4ebe8b),_0x4ebe8b;},__metadata=this&&this[_0x1d51e5(0x186)]||function(_0xa85eee,_0x2147ef){const _0x23069f=_0x1d51e5;if(typeof Reflect===_0x23069f(0x169)&&typeof Reflect[_0x23069f(0x192)]===_0x23069f(0x166))return Reflect['metadata'](_0xa85eee,_0x2147ef);};Object[_0x1d51e5(0x1ad)](exports,_0x1d51e5(0x163),{'value':!![]}),exports[_0x1d51e5(0x19f)]=void 0x0;const chatgpt_service_1=require('../chatgpt/chatgpt.service'),globalConfig_service_1=require(_0x1d51e5(0x18d)),auth_service_1=require(_0x1d51e5(0x177)),user_service_1=require(_0x1d51e5(0x198)),autoreply_service_1=require(_0x1d51e5(0x1a5)),common_1=require(_0x1d51e5(0x1bc)),crypto=require(_0x1d51e5(0x171)),axios_1=require(_0x1d51e5(0x18e)),utils_1=require(_0x1d51e5(0x164));function _0x5e58(){const _0x4e29c4=['wechatOfficialAppSecret','defineProperty','createRandomNonceStr','getConfigs','7QomIoU','非法参数','getQRCodeTicket','loginByOpenId','fetchQRCodeTicket','3795170anQpMY','jiangly','HttpStatus','sha1','BAD_REQUEST','appId:\x20',']]></FromUserName>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<CreateTime>','@nestjs/common','get','54gclnJM','2944248wmuFZd','&code=','chatSyncFree','race','&url=','loginBySceneStr','AuthService','wechatAccessToken','authService',']]></ToUserName>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<FromUserName><![CDATA[','user','__esModule','../../common/utils','getQRSceneStr','function','wechatOfficialAppId','UserService','object','scanedSceneStrMap','wechatOfficialToken','userService','8032838APJeNt','QR_STR_SCENE','来自公众号的询问问题\x20=======>\x20','&secret=','crypto','wechatJsapiTicket','AutoreplyService','5UEpFFg','chatgptService','length','../auth/auth.service','HttpException','join','https://open.weixin.qq.com/connect/oauth2/authorize?appid=','ChatgptService','toFixed','getUserFromOpenId','getQRSceneStrByBind','sceneStrMap','now','checkAutoReply','loginByCode','getRedirectUrl','decorate','getUserById','__metadata','design:paramtypes','9532kHuRcI','scan','jsapi_ticket=','default','710559bWIhJk','../globalConfig/globalConfig.service','axios','https://api.weixin.qq.com/sns/oauth2/access_token?appid=','update','&redirect_uri=','metadata','globalConfigService','由于公众号的回复限制、过长的问题我们可能无法回复、您可以前往我们的官方站点享受更加完善的服务、如果您有更多问题、欢迎像我提问!','verify','hex','log','../user/user.service','sort','来自公众号的回复问题\x20=======>\x20超时导致问题无法回答完整','619208stRnke','getJsapiTicket','genXmlMsg','&response_type=code&scope=snsapi_base&state=weChatLogin#wechat_redirect','OfficialService','genXmlMsgByConfig','1286036YeMONG','67ojakqj','https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=','&timestamp=','../autoreply/autoreply.service','回跳跳转地址:\x20',']]></Content>\x0a\x20\x20\x20\x20</xml>','str:\x20','GlobalConfigService','post','scanBindWx'];_0x5e58=function(){return _0x4e29c4;};return _0x5e58();}let OfficialService=class OfficialService{constructor(_0x5a9483,_0x5a9d72,_0x206e48,_0x5d3d00,_0x2e619e){const _0x8769e3=_0x1d51e5;this['autoreplyService']=_0x5a9483,this[_0x8769e3(0x16c)]=_0x5a9d72,this[_0x8769e3(0x160)]=_0x206e48,this[_0x8769e3(0x193)]=_0x5d3d00,this[_0x8769e3(0x175)]=_0x2e619e,this[_0x8769e3(0x17f)]={},this[_0x8769e3(0x16a)]={};}async['onModuleInit'](){const _0x561e8c=_0x1d51e5;await this[_0x561e8c(0x193)]['getWechatAccessToken'](!![]);}async[_0x1d51e5(0x165)](_0x2c8548){const _0x12617c=_0x1d51e5,{invitedBy:_0x74f747}=_0x2c8548;let _0x2f96f6=(0x0,utils_1[_0x12617c(0x1ae)])(0x20);return _0x74f747&&(_0x2f96f6+=':'+_0x74f747),this[_0x12617c(0x17f)][_0x2f96f6]=!![],_0x2f96f6;}async[_0x1d51e5(0x17e)](_0xd86969){const _0x288e1e=_0x1d51e5,{id:_0x8ec828}=_0xd86969[_0x288e1e(0x162)],_0x5ba159=(0x0,utils_1[_0x288e1e(0x1ae)])(0x20)+'/'+_0x8ec828;return this[_0x288e1e(0x17f)][_0x5ba159]=!![],_0x5ba159;}async[_0x1d51e5(0x1b2)](_0x2d7ad5){const _0x4676fa=_0x1d51e5;return this[_0x4676fa(0x1b4)](_0x2d7ad5);}async[_0x1d51e5(0x183)](_0x5ca242){const _0x18f467=_0x1d51e5,_0x331d62=await this[_0x18f467(0x193)]['getConfigs']([_0x18f467(0x167)]),_0x28c341=_0x18f467(0x17a)+_0x331d62+_0x18f467(0x191)+encodeURIComponent(_0x5ca242)+_0x18f467(0x19e);return console['log'](_0x18f467(0x1a6),_0x28c341),_0x28c341;}async[_0x1d51e5(0x19c)](_0x50d87a){const _0x5b197d=_0x1d51e5,_0x5bc309=(0x0,utils_1[_0x5b197d(0x1ae)])(0x20),_0x13d419=(Date[_0x5b197d(0x180)]()/0x3e8)[_0x5b197d(0x17c)](0x0),_0x95fbff=await this[_0x5b197d(0x193)][_0x5b197d(0x1af)]([_0x5b197d(0x172)]);console[_0x5b197d(0x197)]('jsapiTicket:\x20',_0x95fbff);const _0x4606b6=await this[_0x5b197d(0x193)][_0x5b197d(0x1af)]([_0x5b197d(0x167)]);console['log'](_0x5b197d(0x1ba),_0x4606b6);const _0x3cc5e9=_0x5b197d(0x18a)+_0x95fbff+'&noncestr='+_0x5bc309+_0x5b197d(0x1a4)+_0x13d419+_0x5b197d(0x15c)+_0x50d87a;console['log'](_0x5b197d(0x1a8),_0x3cc5e9);const _0x15399c=this['sha1'](_0x3cc5e9);return{'appId':_0x4606b6,'nonceStr':_0x5bc309,'timestamp':_0x13d419,'signature':_0x15399c};}async[_0x1d51e5(0x1b4)](_0x551fbf){const _0x41c2af=_0x1d51e5,_0x33e966=await this[_0x41c2af(0x193)][_0x41c2af(0x1af)]([_0x41c2af(0x15f)]),_0x4249cd={'action_name':_0x41c2af(0x16e),'action_info':{'scene':{'scene_str':_0x551fbf}}},_0x158735=await axios_1[_0x41c2af(0x18b)][_0x41c2af(0x1aa)](_0x41c2af(0x1a3)+_0x33e966,_0x4249cd),{data:{errmsg:_0x488ad5,ticket:_0x5e1a51}}=_0x158735;if(_0x488ad5)throw new common_1[(_0x41c2af(0x178))](_0x488ad5,common_1[_0x41c2af(0x1b7)][_0x41c2af(0x1b9)]);return _0x5e1a51;}async[_0x1d51e5(0x182)](_0x59fcda,_0x407be6){const _0x5e16e1=_0x1d51e5,_0x5984fb=await this[_0x5e16e1(0x193)][_0x5e16e1(0x1af)](['wechatOfficialAppId']),_0x583dfa=await this[_0x5e16e1(0x193)][_0x5e16e1(0x1af)]([_0x5e16e1(0x1ac)]),_0xc9c1f1=await axios_1[_0x5e16e1(0x18b)][_0x5e16e1(0x1bd)](_0x5e16e1(0x18f)+_0x5984fb+_0x5e16e1(0x170)+_0x583dfa+_0x5e16e1(0x159)+_0x407be6+'&grant_type=authorization_code'),{data:{errmsg:_0xdd4e14,openid:_0x3d6607}}=_0xc9c1f1;if(_0xdd4e14)throw new common_1[(_0x5e16e1(0x178))](_0xdd4e14,common_1['HttpStatus'][_0x5e16e1(0x1b9)]);let _0x5d7c9c;return _0x5d7c9c=await this[_0x5e16e1(0x16c)]['getUserOpenId'](_0x3d6607),!_0x5d7c9c&&(_0x5d7c9c=await this[_0x5e16e1(0x16c)]['getUserFromOpenId'](_0x3d6607)),this[_0x5e16e1(0x160)][_0x5e16e1(0x1b3)](_0x5d7c9c,_0x59fcda);}async[_0x1d51e5(0x189)](_0x2e5a4a,_0x168fd5){const _0x4f0b9b=_0x1d51e5;if(!this[_0x4f0b9b(0x17f)][_0x168fd5])throw new common_1[(_0x4f0b9b(0x178))](_0x4f0b9b(0x1b1),common_1['HttpStatus']['BAD_REQUEST']);const _0x1a0e61=await this[_0x4f0b9b(0x16c)][_0x4f0b9b(0x17d)](_0x2e5a4a,_0x168fd5);this['scanedSceneStrMap'][_0x168fd5]=_0x1a0e61['id'];}async[_0x1d51e5(0x15d)](_0x156eb7,_0x57d39f){const _0xb7325d=_0x1d51e5;if(!this['sceneStrMap'][_0x57d39f])return;const _0xc3687=this['scanedSceneStrMap'][_0x57d39f];if(!_0xc3687)return'';const _0x5727ae=await this['userService'][_0xb7325d(0x185)](_0xc3687);return delete this[_0xb7325d(0x16a)][_0x57d39f],this[_0xb7325d(0x160)][_0xb7325d(0x1b3)](_0x5727ae,_0x156eb7);}async[_0x1d51e5(0x1ab)](_0x432bca,_0x156a41){const _0x37f275=_0x1d51e5;if(!this[_0x37f275(0x17f)][_0x156a41])throw new common_1[(_0x37f275(0x178))](_0x37f275(0x1b1),common_1[_0x37f275(0x1b7)][_0x37f275(0x1b9)]);const _0x22c969=_0x156a41['split']('/')[0x1],_0x31b8b7=await this[_0x37f275(0x16c)]['bindWx'](_0x432bca,_0x22c969);this[_0x37f275(0x16a)][_0x156a41]=_0x31b8b7;}async['bindWxBySceneStr'](_0xcc3efe,_0x2d920a){const _0xde121a=_0x1d51e5;if(!this[_0xde121a(0x17f)][_0x2d920a])throw new common_1[(_0xde121a(0x178))](_0xde121a(0x1b1),common_1['HttpStatus'][_0xde121a(0x1b9)]);const {id:_0x511696}=_0xcc3efe['user'],_0x2473ae=this[_0xde121a(0x16a)][_0x2d920a];if(!_0x2473ae)return'';return delete this['scanedSceneStrMap'][_0x2d920a],_0x2473ae;}async[_0x1d51e5(0x195)](_0x379881,_0x2b53ed,_0x25cafb){const _0x86ccc0=_0x1d51e5,_0x28f157=await this[_0x86ccc0(0x193)]['getConfigs']([_0x86ccc0(0x16b)])||_0x86ccc0(0x1b6);return await this[_0x86ccc0(0x1b8)]([_0x28f157,_0x2b53ed,_0x25cafb][_0x86ccc0(0x199)]()[_0x86ccc0(0x179)](''))==_0x379881;}['sha1'](_0xfdb840){const _0x1d8db1=_0x1d51e5;return crypto['createHash']('sha1')[_0x1d8db1(0x190)](_0xfdb840)['digest'](_0x1d8db1(0x196));}async[_0x1d51e5(0x1a0)](_0x12d995,_0x1f56db){const _0x3f01b7=_0x1d51e5,_0x22f9b9=await this[_0x3f01b7(0x193)][_0x3f01b7(0x1af)]([_0x1f56db]);return this[_0x3f01b7(0x19d)](_0x12d995,_0x22f9b9);}async[_0x1d51e5(0x19d)](_0x293b7b,_0xb95124){const _0x296049=_0x1d51e5;return'\x0a\x20\x20\x20\x20<xml>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<ToUserName><![CDATA['+_0x293b7b['fromusername'][0x0]+_0x296049(0x161)+_0x293b7b['tousername'][0x0]+_0x296049(0x1bb)+new Date()['getTime']()+'</CreateTime>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<MsgType><![CDATA[text]]></MsgType>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<Content><![CDATA['+_0xb95124+_0x296049(0x1a7);}async['aotoPlay'](_0x38195e){const _0x126604=_0x1d51e5,_0xe5705a=new Promise((_0x40debb,_0x4a9dfb)=>{setTimeout(()=>{_0x4a9dfb(new Error('请求超时'));},0x12c0);});let _0x5d7b57='';try{console[_0x126604(0x197)](_0x126604(0x16f),_0x38195e);const _0x3dcd47=await Promise[_0x126604(0x15b)]([this['chatgptService'][_0x126604(0x15a)](_0x38195e),_0xe5705a]);_0x5d7b57=_0x3dcd47||await this['autoreplyService'][_0x126604(0x181)](_0x38195e);}catch(_0x5204c6){console[_0x126604(0x197)](_0x126604(0x19a)),_0x5d7b57=await this[_0x126604(0x193)][_0x126604(0x1af)](['officialAutoReplyText'])||_0x126604(0x194);}return _0x5d7b57;}};OfficialService=__decorate([(0x0,common_1['Injectable'])(),__metadata(_0x1d51e5(0x187),[autoreply_service_1[_0x1d51e5(0x173)],user_service_1[_0x1d51e5(0x168)],auth_service_1[_0x1d51e5(0x15e)],globalConfig_service_1[_0x1d51e5(0x1a9)],chatgpt_service_1[_0x1d51e5(0x17b)]])],OfficialService),exports[_0x1d51e5(0x19f)]=OfficialService;