ebb46d3353da67c17571a5e76d73b1cef7415b21
[motion.git] / server / config / agi / lib / scripts / index.js
1 var _0x9207=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x73","\x70\x61\x74\x68","\x68\x74\x74\x70","\x68\x74\x74\x70\x73","\x70\x61\x72\x73\x65","\x75\x72\x6C","\x62\x6C\x75\x65\x62\x69\x72\x64","\x72\x61\x6E\x64\x6F\x6D\x73\x74\x72\x69\x6E\x67","\x73\x6F\x78","\x67\x6F\x6F\x67\x6C\x65\x2D\x74\x74\x73\x2D\x61\x70\x69","\x75\x74\x69\x6C","\x71\x75\x65\x72\x79\x73\x74\x72\x69\x6E\x67","\x6D\x6F\x6D\x65\x6E\x74","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x61\x70\x69\x2E\x69\x73\x70\x65\x65\x63\x68\x2E\x6F\x72\x67\x2F\x61\x70\x69\x2F\x72\x65\x73\x74","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x74\x74\x70\x73\x3A","\x68\x6F\x73\x74","\x57\x48\x41\x54\x5F\x45\x56\x45\x52","\x65\x6E\x64","\x65\x72\x72\x6F\x72","\x6F\x6E","\x73\x74\x61\x74\x75\x73\x43\x6F\x64\x65","\x72\x65\x71\x75\x65\x73\x74\x20\x74\x6F\x20","\x20\x66\x61\x69\x6C\x65\x64\x2C\x20\x73\x74\x61\x74\x75\x73\x20\x63\x6F\x64\x65\x20\x3D\x20","\x20\x28","\x73\x74\x61\x74\x75\x73\x4D\x65\x73\x73\x61\x67\x65","\x29","\x63\x72\x65\x61\x74\x65\x57\x72\x69\x74\x65\x53\x74\x72\x65\x61\x6D","\x66\x69\x6E\x69\x73\x68","\x63\x6C\x6F\x73\x65","\x75\x6E\x6C\x69\x6E\x6B","\x70\x69\x70\x65","\x67\x65\x74","","\x64\x61\x74\x61","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x68\x6F\x73\x74\x6E\x61\x6D\x65","\x70\x6F\x72\x74","\x50\x4F\x53\x54","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x6A\x73\x6F\x6E","\x75\x74\x66\x38","\x73\x65\x74\x45\x6E\x63\x6F\x64\x69\x6E\x67","\x72\x65\x71\x75\x65\x73\x74","\x77\x72\x69\x74\x65","\x77\x61\x76","\x74\x72\x61\x6E\x73\x63\x6F\x64\x65","\x73\x74\x61\x72\x74","\x72\x65\x61\x64\x46\x69\x6C\x65\x53\x79\x6E\x63","\x62\x61\x73\x65\x36\x34","\x67\x6F\x6F\x67\x6C\x65\x54\x54\x53","\x2E","\x73\x70\x6C\x69\x74","\x74\x68\x65\x6E","\x74\x6D\x70","\x67\x65\x6E\x65\x72\x61\x74\x65","\x2E\x77\x61\x76","\x72\x65\x73\x6F\x6C\x76\x65","\x2E\x6D\x70\x33","\x65\x6E","\x69\x73\x70\x65\x65\x63\x68\x54\x54\x53","\x25\x73\x3F\x61\x70\x69\x6B\x65\x79\x3D\x25\x73\x26\x61\x63\x74\x69\x6F\x6E\x3D\x63\x6F\x6E\x76\x65\x72\x74\x26\x74\x65\x78\x74\x3D\x25\x73\x26\x76\x6F\x69\x63\x65\x3D\x25\x73\x26\x73\x70\x65\x65\x64\x3D\x25\x73\x26\x66\x6F\x72\x6D\x61\x74\x3D\x6D\x70\x33","\x66\x6F\x72\x6D\x61\x74","\x69\x73\x70\x65\x65\x63\x68\x41\x53\x52","\x25\x73\x3F\x61\x70\x69\x6B\x65\x79\x3D\x25\x73\x26\x61\x63\x74\x69\x6F\x6E\x3D\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x26\x6C\x6F\x63\x61\x6C\x65\x3D\x25\x73\x26\x63\x6F\x6E\x74\x65\x6E\x74\x2D\x74\x79\x70\x65\x3D\x61\x75\x64\x69\x6F\x2F\x78\x2D\x77\x61\x76\x26\x61\x75\x64\x69\x6F\x3D\x25\x73\x26\x25\x73","\x6D\x6F\x64\x65\x6C\x3D\x25\x73","\x66\x72\x65\x65\x66\x6F\x72\x6D\x3D\x33","\x74\x69\x67\x65\x72\x44\x69\x61\x6C\x43\x61\x6C\x6C\x62\x61\x63\x6B","\x68\x74\x74\x70\x3A\x2F\x2F\x6C\x6F\x63\x61\x6C\x68\x6F\x73\x74\x2F\x61\x70\x69\x2F\x72\x65\x73\x74\x2F\x63\x6F\x6E\x74\x61\x63\x74\x2F\x69\x6E\x73\x65\x72\x74","\x2C","\x74\x72\x69\x6D","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x6D\x69\x6E\x75\x74\x65\x73","\x61\x64\x64","\x73\x74\x61\x74\x75\x73","\x64\x69\x72\x4E\x61\x6D\x65"];_0x9207[0];var fs=require(_0x9207[1]);var path=require(_0x9207[2]);var http=require(_0x9207[3]);var https=require(_0x9207[4]);var urlParse=require(_0x9207[6])[_0x9207[5]];var BPromise=require(_0x9207[7]);var rs=require(_0x9207[8]);var sox=require(_0x9207[9]);var tts=require(_0x9207[10]);var util=require(_0x9207[11]);var querystring=require(_0x9207[12]);var moment=require(_0x9207[13]);var ISPEECH_API=_0x9207[14];function downloadFile(_0xa602xf,_0xa602x10){return  new BPromise(function(_0xa602x11,_0xa602x12){var _0xa602x13=urlParse(_0xa602xf);var _0xa602x14=_0xa602x13[_0x9207[15]]=== _0x9207[16]?https:http;var _0xa602x15={host:_0xa602x13[_0x9207[17]],path:_0xa602x13[_0x9207[2]],headers:{"\x75\x73\x65\x72\x2D\x61\x67\x65\x6E\x74":_0x9207[18]}};_0xa602x14[_0x9207[33]](_0xa602x15,function(_0xa602x17){if(_0xa602x17[_0x9207[22]]!== 200){_0xa602x12( new Error(_0x9207[23]+ _0xa602xf+ _0x9207[24]+ _0xa602x17[_0x9207[22]]+ _0x9207[25]+ _0xa602x17[_0x9207[26]]+ _0x9207[27]));return};var _0xa602x18=fs[_0x9207[28]](_0xa602x10);_0xa602x18[_0x9207[21]](_0x9207[29],function(){_0xa602x18[_0x9207[30]](_0xa602x11)});_0xa602x18[_0x9207[21]](_0x9207[20],function(_0xa602x16){fs[_0x9207[31]](_0xa602x10);_0xa602x12(_0xa602x16)});_0xa602x17[_0x9207[32]](_0xa602x18)})[_0x9207[21]](_0x9207[20],function(_0xa602x16){_0xa602x12(_0xa602x16)})[_0x9207[19]]()})}function uploadFile(_0xa602xf){return  new BPromise(function(_0xa602x11,_0xa602x12){var _0xa602x13=urlParse(_0xa602xf);var _0xa602x14=_0xa602x13[_0x9207[15]]=== _0x9207[16]?https:http;var _0xa602x15={host:_0xa602x13[_0x9207[17]],path:_0xa602x13[_0x9207[2]],headers:{"\x75\x73\x65\x72\x2D\x61\x67\x65\x6E\x74":_0x9207[18]}};_0xa602x14[_0x9207[33]](_0xa602x15,function(_0xa602x17){if(_0xa602x17[_0x9207[22]]!== 200){_0xa602x12( new Error(_0x9207[23]+ _0xa602xf+ _0x9207[24]+ _0xa602x17[_0x9207[22]]+ _0x9207[25]+ _0xa602x17[_0x9207[26]]+ _0x9207[27]));return};var _0xa602x1a=_0x9207[34];_0xa602x17[_0x9207[21]](_0x9207[35],function(_0xa602x1b){_0xa602x1a+= _0xa602x1b});_0xa602x17[_0x9207[21]](_0x9207[19],function(){_0xa602x11(_0xa602x1a)})})[_0x9207[21]](_0x9207[20],function(_0xa602x16){_0xa602x12(_0xa602x16)})[_0x9207[19]]()})}function tigerDialAPI(_0xa602xf,_0xa602x1d){return  new BPromise(function(_0xa602x11,_0xa602x12){var _0xa602x1e=JSON[_0x9207[36]](_0xa602x1d);var _0xa602x13=urlParse(_0xa602xf);var _0xa602x14=_0xa602x13[_0x9207[15]]=== _0x9207[16]?https:http;var _0xa602x15={hostname:_0xa602x13[_0x9207[37]],path:_0xa602x13[_0x9207[2]],port:_0xa602x13[_0x9207[38]],method:_0x9207[39],headers:{"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0x9207[40]}};var _0xa602x1f=_0xa602x14[_0x9207[43]](_0xa602x15,function(_0xa602x17){if(_0xa602x17[_0x9207[22]]!== 200){_0xa602x12( new Error(_0x9207[23]+ _0xa602xf+ _0x9207[24]+ _0xa602x17[_0x9207[22]]+ _0x9207[25]+ _0xa602x17[_0x9207[26]]+ _0x9207[27]));return};_0xa602x17[_0x9207[42]](_0x9207[41]);var _0xa602x1a=_0x9207[34];_0xa602x17[_0x9207[21]](_0x9207[35],function(_0xa602x1b){_0xa602x1a+= _0xa602x1b});_0xa602x17[_0x9207[21]](_0x9207[19],function(){_0xa602x11(_0xa602x1a)})});_0xa602x1f[_0x9207[21]](_0x9207[20],function(_0xa602x16){_0xa602x12(_0xa602x16)});_0xa602x1f[_0x9207[44]](_0xa602x1e);_0xa602x1f[_0x9207[19]]()})}function convertFile(_0xa602x18,_0xa602x10){return  new BPromise(function(_0xa602x11,_0xa602x12){var _0xa602x21=sox[_0x9207[46]](_0xa602x18,_0xa602x10,{sampleRate:8000,format:_0x9207[45],channelCount:1,bitRate:192* 1024,compressionQuality:5});_0xa602x21[_0x9207[21]](_0x9207[20],function(_0xa602x16){_0xa602x12(_0xa602x16)});_0xa602x21[_0x9207[21]](_0x9207[19],function(){_0xa602x11()});_0xa602x21[_0x9207[47]]()})}function base64Encode(_0xa602x18){var _0xa602x23=fs[_0x9207[48]](_0xa602x18);return  new Buffer(_0xa602x23).toString(_0x9207[49])}exports[_0x9207[50]]= function(_0xa602x24,_0xa602x25){var _0xa602x26;var _0xa602x27;return tts(_0xa602x24,_0xa602x25|| _0x9207[59],1)[_0x9207[53]](function(_0xa602xf){_0xa602x26= path[_0x9207[57]](__dirname,_0x9207[54],rs[_0x9207[55]](4)+ _0x9207[58]);return downloadFile(_0xa602xf,_0xa602x26)})[_0x9207[53]](function(){_0xa602x27= path[_0x9207[57]](__dirname,_0x9207[54],rs[_0x9207[55]](4)+ _0x9207[56]);return convertFile(_0xa602x26,_0xa602x27)})[_0x9207[53]](function(){fs[_0x9207[31]](_0xa602x26);return _0xa602x27[_0x9207[52]](_0x9207[51])[0]})};exports[_0x9207[60]]= function(_0xa602x28,_0xa602x24,_0xa602x25,_0xa602x29){var _0xa602xf=util[_0x9207[62]](_0x9207[61],ISPEECH_API,_0xa602x28,encodeURIComponent(_0xa602x24),_0xa602x25,_0xa602x29);var _0xa602x26=path[_0x9207[57]](__dirname,_0x9207[54],rs[_0x9207[55]](4)+ _0x9207[58]);var _0xa602x27;return downloadFile(_0xa602xf,_0xa602x26)[_0x9207[53]](function(){_0xa602x27= path[_0x9207[57]](__dirname,_0x9207[54],rs[_0x9207[55]](4)+ _0x9207[56]);return convertFile(_0xa602x26,_0xa602x27)})[_0x9207[53]](function(){fs[_0x9207[31]](_0xa602x26);return _0xa602x27[_0x9207[52]](_0x9207[51])[0]})};exports[_0x9207[63]]= function(_0xa602x26,_0xa602x28,_0xa602x25,_0xa602x2a){var _0xa602xf=util[_0x9207[62]](_0x9207[64],ISPEECH_API,_0xa602x28,_0xa602x25,base64Encode(_0xa602x26),_0xa602x2a?util[_0x9207[62]](_0x9207[65],encodeURIComponent(_0xa602x2a)):_0x9207[66]);return uploadFile(_0xa602xf)[_0x9207[53]](function(_0xa602x17){return querystring[_0x9207[5]](_0xa602x17)})};exports[_0x9207[67]]= function(_0xa602x2b,_0xa602x2c,_0xa602x2d,_0xa602x2e,_0xa602x2f){var _0xa602xf=_0x9207[68];var _0xa602x1d={id_list:parseInt(_0xa602x2b),name:_0xa602x2c|| _0x9207[34],phones:_0xa602x2d[_0x9207[70]]()[_0x9207[52]](_0x9207[69]),description:_0xa602x2e|| _0x9207[34],planningtime:moment()[_0x9207[73]](_0xa602x2f|| 5,_0x9207[72])[_0x9207[62]](_0x9207[71])};return tigerDialAPI(_0xa602xf,_0xa602x1d)[_0x9207[53]](function(_0xa602x17){var _0xa602x30=JSON[_0x9207[5]](_0xa602x17);if(_0xa602x30[_0x9207[74]]> 0){return true};return false})};exports[_0x9207[75]]= function(){return __dirname}