f0ed0b384ed7b0e96091510ab6a5c0b8e0607e74
[motion.git] / server / config / chat.js
1 var _0xab77=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x2E\x2F\x63\x68\x61\x74","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74","\x52\x65\x70\x6F\x72\x74\x43\x68\x61\x74\x53\x65\x73\x73\x69\x6F\x6E","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x53\x6D\x73\x4D\x65\x73\x73\x61\x67\x65","\x53\x65\x74\x74\x69\x6E\x67","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x75\x74\x69\x6C","\x6D\x6F\x6D\x65\x6E\x74","\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73","\x6B\x75\x65","\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x2E\x2F\x75\x74\x69\x6C","\x63\x68\x61\x74","\x2E\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x63\x72\x65\x61\x74\x65\x51\x75\x65\x75\x65","\x65\x78\x69\x74","\x70\x69\x64","\x70\x72\x6F\x63\x65\x73\x73","\x64\x61\x74\x61","\x72\x65\x6D\x6F\x76\x65","\x6F\x6E","\x6D\x65\x73\x73\x61\x67\x65","\x4D\x61\x69\x6C\x52\x6F\x6F\x6D\x49\x64","\x6D\x73\x67","\x63\x72\x65\x61\x74\x65","\x63\x72\x65\x61\x74\x65\x4D\x61\x69\x6C","\x63\x72\x65\x61\x74\x65\x53\x6D\x73","\x74\x79\x70\x65","\x73\x65\x6E\x64","\x63\x72\x65\x61\x74\x65\x43\x68\x61\x74\x51\x75\x65\x75\x65\x53\x65\x73\x73\x69\x6F\x6E","\x72\x6F\x6F\x74","\x2F\x73\x65\x72\x76\x65\x72\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x66\x6F\x72\x6B\x65\x64\x5F\x72\x6F\x75\x74\x69\x6E\x67\x2F\x63\x68\x61\x74\x2F\x69\x6E\x64\x65\x78\x2E\x6A\x73","\x6A\x6F\x69\x6E","\x66\x6F\x72\x6B","\x6F\x62\x6A","\x70\x75\x73\x68","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x20\x69\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x20\x65\x72\x72\x6F\x72","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x43\x48\x41\x54\x20\x77\x65\x62\x73\x69\x74\x65\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E","\x69\x6E\x66\x6F","\x67\x65\x74","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x64","\x63\x68\x61\x6E\x67\x65\x64","\x45\x72\x72\x6F\x72\x20\x6F\x6E\x20\x6D\x61\x69\x6C\x20\x61\x63\x63\x65\x70\x74","\x72\x6F\x6F\x6D\x69\x64","\x66\x69\x6E\x64","\x73\x74\x6F\x70","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x74\x68\x65\x6E","\x6D\x65\x6D\x62\x65\x72\x69\x64","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x6D\x61\x74","\x75\x6E\x69\x71\x75\x65\x69\x64","\x75\x70\x64\x61\x74\x65","\x72\x65\x6A\x65\x63\x74\x65\x64\x41\x74","\x72\x65\x6A\x65\x63\x74","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x77\x65\x62\x73\x69\x74\x65\x69\x64","\x61\x63\x63\x65\x70\x74","\x65\x78\x74\x65\x72\x6E\x61\x6C","\x73\x74\x61\x72\x74","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x69\x64","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65\x49\x64","\x77\x65\x62\x73\x69\x74\x65","\x76\x69\x73\x69\x74\x6F\x72\x69\x64","\x70\x61\x72\x61\x6D\x31","\x76\x69\x73\x69\x74\x6F\x72\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x76\x69\x73\x69\x74\x6F\x72\x65\x6D\x61\x69\x6C","\x65\x6D\x61\x69\x6C","\x73\x61\x76\x65","\x72\x65\x6D\x6F\x76\x65\x4F\x6E\x43\x6F\x6D\x70\x6C\x65\x74\x65","\x4E\x65\x77\x20\x63\x68\x61\x74\x20\x66\x72\x6F\x6D\x3A\x20\x25\x73","\x61\x63\x63\x6F\x75\x6E\x74\x69\x64","\x61\x63\x63\x6F\x75\x6E\x74\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x61\x63\x63\x6F\x75\x6E\x74\x61\x64\x64\x72\x65\x73\x73","\x61\x64\x64\x72\x65\x73\x73","\x77\x65\x62\x73\x69\x74\x65\x6E\x61\x6D\x65","\x77\x65\x62\x73\x69\x74\x65\x61\x64\x64\x72\x65\x73\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x73\x74\x61\x74\x75\x73","\x43\x4C\x4F\x53\x45\x44","\x63\x6C\x6F\x73\x65","\x61\x62\x61\x6E\x64\x6F\x6E","\x53\x54\x4F\x50\x20\x53\x43\x48\x45\x44\x55\x4C\x45\x52\x20\x49\x4E\x53\x54\x41\x4E\x43\x45\x2C\x20\x49\x4E\x54\x45\x52\x41\x43\x54\x49\x4F\x4E\x3A","\x64\x69\x61\x6C\x70\x6C\x61\x6E\x20\x65\x6E\x64\x65\x64","\x6C\x6F\x67","\x41\x42\x41\x4E\x44\x4F\x4E","\x63\x68\x61\x74\x52\x6F\x75\x74\x69\x6E\x67\x43\x61\x70\x61\x63\x69\x74\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x61\x63\x63\x65\x70\x74\x4D\x65\x74\x68\x6F\x64","\x61\x63\x63\x65\x70\x74\x55\x72\x6C","\x43\x68\x61\x74\x20\x77\x65\x62\x73\x69\x74\x65\x20\x3C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x61\x63\x63\x65\x70\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x64\x65\x62\x75\x67","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6C\x65\x6E\x67\x74\x68","\x61\x63\x74\x69\x6F\x6E\x73","\x65\x6E\x61\x62\x6C\x65\x64","\x65\x78\x65\x63\x41\x63\x74\x69\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x72\x65\x6A\x65\x63\x74\x4D\x65\x74\x68\x6F\x64","\x72\x65\x6A\x65\x63\x74\x55\x72\x6C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x72\x65\x6A\x65\x63\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x63\x6C\x6F\x73\x65\x4D\x65\x74\x68\x6F\x64","\x63\x6C\x6F\x73\x65\x55\x72\x6C","\x3E\x20\x65\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x63\x6C\x6F\x73\x65\x20\x77\x65\x62\x68\x6F\x6F\x6B","\x57\x65\x62\x68\x6F\x6F\x6B\x20\x6E\x6F\x74\x20\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x64","\x43\x68\x61\x74\x20\x77\x65\x62\x68\x6F\x6F\x6B\x20\x72\x65\x71\x75\x65\x73\x74\x20\x66\x61\x69\x6C\x65\x64\x21","\x72\x65\x71\x75\x65\x73\x74\x20\x73\x75\x63\x63\x65\x73\x73\x65\x66\x75\x6C\x21","\x73\x65\x6E\x64\x52\x65\x71\x75\x65\x73\x74","\x43\x68\x61\x74\x20\x77\x65\x62\x73\x69\x74\x65\x3A\x20","\x20\x43\x72\x65\x61\x74\x65","\x20\x55\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x75\x6E\x73\x68\x69\x66\x74","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79"];_0xab77[0];var ChatWebsite=require(_0xab77[2])[_0xab77[1]];var ChatVisitor=require(_0xab77[2])[_0xab77[3]];var ChatRoom=require(_0xab77[2])[_0xab77[4]];var Website=require(_0xab77[5]);var ReportChat=require(_0xab77[2])[_0xab77[6]];var ReportChatSession=require(_0xab77[2])[_0xab77[7]];var MailMessage=require(_0xab77[2])[_0xab77[8]];var SmsMessage=require(_0xab77[2])[_0xab77[9]];var Setting=require(_0xab77[2])[_0xab77[10]];var _=require(_0xab77[11]);var path=require(_0xab77[12]);var util=require(_0xab77[13]);var moment=require(_0xab77[14]);var cp=require(_0xab77[15]);var kue=require(_0xab77[16]);var config=require(_0xab77[17]);var Util=require(_0xab77[18]);var logger=require(_0xab77[20])(_0xab77[19]);var chatwebsites;var processes=[];var queue=kue[_0xab77[21]]();var ami;function handleChat(_0xe469x18,_0xe469x19){var _0xe469x1a=cp[_0xab77[40]](path[_0xab77[39]](config[_0xab77[37]],_0xab77[38]))[_0xab77[27]](_0xab77[28],function(_0xe469x1c){switch(_0xe469x1c[_0xab77[34]]){case _0xab77[32]:delete _0xe469x1c[_0xab77[30]][_0xab77[29]];return MailMessage[_0xab77[31]](_0xe469x1c[_0xab77[30]]);case _0xab77[33]:return SmsMessage[_0xab77[31]](_0xe469x1c[_0xab77[30]]);case _0xab77[36]:if(ami){ami[_0xab77[35]]({message:_0xe469x1c[_0xab77[34]],doc:_0xe469x1c[_0xab77[30]]})};break}})[_0xab77[27]](_0xab77[22],function(){var _0xe469x1b=_[_0xab77[26]](processes,{pid:_0xe469x18[_0xab77[25]][_0xab77[24]][_0xab77[23]]});_0xe469x19()});_0xe469x1a[_0xab77[35]](_0xe469x18[_0xab77[25]][_0xab77[41]]);_0xe469x18[_0xab77[25]][_0xab77[24]][_0xab77[24]]= _0xe469x1a;_0xe469x18[_0xab77[25]][_0xab77[24]][_0xab77[23]]= _0xe469x1a[_0xab77[23]];processes[_0xab77[42]](_0xe469x18[_0xab77[25]][_0xab77[24]])}module[_0xab77[43]]= function(_0xe469x1d){ami= _0xe469x1d;return Setting[_0xab77[55]]({where:{id:1},attributes:[_0xab77[73],_0xab77[102]],raw:true})[_0xab77[58]](function(_0xe469x29){if(_0xe469x29){queue[_0xab77[24]](_0xab77[19],_0xe469x29[_0xab77[102]],handleChat)};return ChatWebsite[_0xab77[103]]()})[_0xab77[58]](function(_0xe469x1f){logger[_0xab77[49]](_0xab77[48]);chatwebsites= _0xe469x1f;synch(chatwebsites);ReportChat[_0xab77[66]](function(_0xe469x20,_0xe469x21){var _0xe469x22=_0xe469x20[_0xab77[50]]({plain:true});if(_0xe469x20[_0xab77[52]](_0xab77[51])){return ReportChatSession[_0xab77[63]]({memberid:_0xe469x22[_0xab77[59]],membername:_0xe469x22[_0xab77[57]],leaveAt:moment()[_0xab77[61]](_0xab77[60])},{where:{uniqueid:_0xe469x22[_0xab77[62]],leaveAt:null},individualHooks:true})[_0xab77[58]](function(){var _0xe469x23=_[_0xab77[55]](processes,{roomid:_0xe469x22[_0xab77[54]],channel:_0xab77[19]});if(_0xe469x23){_0xe469x23[_0xab77[24]][_0xab77[35]]({type:_0xab77[56],membername:_0xe469x22[_0xab77[57]]})}})[_0xab77[47]](function(_0xe469x1e){logger[_0xab77[46]](_0xab77[53],_0xe469x1e)})}else {if(_0xe469x20[_0xab77[52]](_0xab77[64])){var _0xe469x23=_[_0xab77[55]](processes,{roomid:_0xe469x22[_0xab77[54]],channel:_0xab77[19]});if(_0xe469x23){_0xe469x23[_0xab77[24]][_0xab77[35]]({type:_0xab77[65],id:_0xe469x22[_0xab77[59]],membername:_0xe469x22[_0xab77[57]]})}}}});ReportChat[_0xab77[66]](function(_0xe469x20){var _0xe469x24=_[_0xab77[55]](chatwebsites,{id:_0xe469x20[_0xab77[67]]});if(_0xe469x24&& _0xe469x20[_0xab77[52]](_0xab77[51])){webhook(_0xe469x20,_0xe469x24,_0xab77[68])};if(_0xe469x24&& _0xe469x20[_0xab77[52]](_0xab77[64])){webhook(_0xe469x20,_0xe469x24,_0xab77[65])}});ChatRoom[_0xab77[93]](function(_0xe469x20){var _0xe469x25=_0xe469x20[_0xab77[50]]({plain:true});if(_0xe469x25[_0xab77[34]]=== _0xab77[69]){var _0xe469x26={type:_0xab77[70],param1:{channel:_0xab77[19],uniqueid:util[_0xab77[61]](_0xab77[71],moment()[_0xab77[72]](),_0xe469x25[_0xab77[73]]),roomid:_0xe469x25[_0xab77[73]],accountid:_0xe469x25[_0xab77[74]],accountname:_0xe469x25[_0xab77[75]]}};ChatWebsite[_0xab77[92]](_0xe469x25.ChatWebsiteId,{raw:true,attributes:[_0xab77[73],_0xab77[87],_0xab77[89]]})[_0xab77[58]](function(_0xe469x28){_0xe469x26[_0xab77[77]][_0xab77[85]]= _0xe469x28[_0xab77[73]];_0xe469x26[_0xab77[77]][_0xab77[86]]= _0xe469x28[_0xab77[87]];_0xe469x26[_0xab77[77]][_0xab77[88]]= _0xe469x28[_0xab77[89]];_0xe469x26[_0xab77[77]][_0xab77[67]]= _0xe469x28[_0xab77[73]];_0xe469x26[_0xab77[77]][_0xab77[90]]= _0xe469x28[_0xab77[87]];_0xe469x26[_0xab77[77]][_0xab77[91]]= _0xe469x28[_0xab77[89]];return ChatVisitor[_0xab77[92]](_0xe469x25.ChatVisitorId,{raw:true,attributes:[_0xab77[73],_0xab77[79],_0xab77[81]]})})[_0xab77[58]](function(_0xe469x27){_0xe469x26[_0xab77[77]][_0xab77[76]]= _0xe469x27[_0xab77[73]];_0xe469x26[_0xab77[77]][_0xab77[78]]= _0xe469x27[_0xab77[79]];_0xe469x26[_0xab77[77]][_0xab77[80]]= _0xe469x27[_0xab77[81]];return queue[_0xab77[31]](_0xab77[19],{title:util[_0xab77[61]](_0xab77[84],_0xe469x27[_0xab77[81]]),process:{id:_0xe469x25[_0xab77[73]],channel:_0xab77[19],roomid:_0xe469x25[_0xab77[73]]},obj:_0xe469x26})[_0xab77[83]](true)[_0xab77[82]]()})[_0xab77[47]](function(_0xe469x1e){console[_0xab77[46]](_0xe469x1e)})}});ChatRoom[_0xab77[66]](function(_0xe469x20){var _0xe469x24=_[_0xab77[55]](chatwebsites,{id:_0xe469x20[_0xab77[74]]});if(_0xe469x24&& _0xe469x20[_0xab77[52]](_0xab77[94])&& _0xe469x20[_0xab77[94]]=== _0xab77[95]){webhook(_0xe469x20,_0xe469x24,_0xab77[96])}});ReportChatSession[_0xab77[66]](function(_0xe469x20,_0xe469x21){if(_0xe469x20[_0xab77[52]](_0xab77[97])&& _0xe469x20[_0xab77[97]]){console[_0xab77[49]](util[_0xab77[61]](_0xab77[98],_0xe469x20[_0xab77[54]]));var _0xe469x1b=_[_0xab77[55]](processes,{channel:_0xab77[19],roomid:_0xe469x20[_0xab77[54]]});if(_0xe469x1b){_0xe469x1b[_0xab77[24]][_0xab77[35]]({type:_0xab77[97]})};return ChatRoom[_0xab77[63]]({status:_0xab77[101]},{where:{id:_0xe469x20[_0xab77[54]]},individualHooks:true})[_0xab77[58]](function(){console[_0xab77[100]](_0xab77[99])})[_0xab77[47]](function(_0xe469x1e){console[_0xab77[46]]()})}})})[_0xab77[47]](function(_0xe469x1e){logger[_0xab77[46]](_0xab77[44],_0xe469x1e[_0xab77[45]])})};function webhook(_0xe469x20,_0xe469x24,_0xe469x2b){var _0xe469x2c=_0xe469x24;switch(_0xe469x2b){case _0xab77[68]:if(_0xe469x2c[_0xab77[104]]&& _0xe469x2c[_0xab77[105]]){logger[_0xab77[108]](_0xab77[106]+ _0xe469x2c[_0xab77[87]]+ _0xab77[107]);execRequest(_0xe469x20[_0xab77[109]],_0xe469x2c[_0xab77[104]],_0xe469x2c[_0xab77[105]])};if(_0xe469x2c[_0xab77[111]][_0xab77[110]]){_[_0xab77[114]](_0xe469x2c[_0xab77[111]],function(_0xe469x2d){if(_0xe469x2d[_0xab77[112]]){Util[_0xab77[113]](_0xe469x2d,_0xe469x20)}})};break;case _0xab77[65]:if(_0xe469x2c[_0xab77[115]]&& _0xe469x2c[_0xab77[116]]){logger[_0xab77[108]](_0xab77[106]+ _0xe469x2c[_0xab77[87]]+ _0xab77[117]);execRequest(_0xe469x20[_0xab77[109]],_0xe469x2c[_0xab77[115]],_0xe469x2c[_0xab77[116]])};break;case _0xab77[96]:if(_0xe469x2c[_0xab77[118]]&& _0xe469x2c[_0xab77[119]]){logger[_0xab77[108]](_0xab77[106]+ _0xe469x2c[_0xab77[87]]+ _0xab77[120]);execRequest(_0xe469x20[_0xab77[109]],_0xe469x2c[_0xab77[118]],_0xe469x2c[_0xab77[119]])};break;default:logger[_0xab77[46]](_0xab77[121])}}function execRequest(_0xe469x20,_0xe469x2f,_0xe469x30){Util[_0xab77[124]](_0xe469x20,_0xe469x2f,_0xe469x30)[_0xab77[58]](function(_0xe469x31){logger[_0xab77[108]](_0xab77[123])})[_0xab77[47]](function(_0xe469x1e){logger[_0xab77[46]](_0xab77[122],_0xe469x1e[_0xab77[45]])})}function synch(chatwebsites){ChatWebsite[_0xab77[93]](function(_0xe469x20){logger[_0xab77[108]](_0xab77[125]+ _0xe469x20[_0xab77[87]]+ _0xab77[126]);chatwebsites[_0xab77[42]](_0xe469x20)});ChatWebsite[_0xab77[66]](function(_0xe469x20){var _0xe469x33=_[_0xab77[55]](chatwebsites,{id:_0xe469x20[_0xab77[73]]});if(_0xe469x33){logger[_0xab77[108]](_0xab77[125]+ _0xe469x33[_0xab77[87]]+ _0xab77[127]);_[_0xab77[128]](_0xe469x33,_0xe469x20)}else {chatwebsites[_0xab77[129]](_0xe469x20)}});ChatWebsite[_0xab77[130]](function(_0xe469x20){_[_0xab77[26]](chatwebsites,{id:_0xe469x20[_0xab77[73]]})})}