Built motion from commit dec9cf4.|0.0.134
[motion.git] / server / config / automations / chat.js
1 var _0xa08e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x6F\x6D\x65\x6E\x74","\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x45\x78\x65\x63\x75\x74\x69\x6E\x67\x20\x43\x68\x61\x74\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20","\x6C\x6F\x67","\x43\x68\x61\x74\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20\x65\x78\x65\x63\x20\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x69\x64","\x64\x61\x74\x61\x31","\x73\x74\x61\x74\x75\x73","\x61\x63\x74\x69\x6F\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x41\x63\x74\x69\x6F\x6E\x73","\x74\x68\x65\x6E","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x70\x75\x73\x68","\x41\x6C\x6C","\x41\x6E\x79","\x6C\x65\x6E\x67\x74\x68","\x24\x61\x6E\x64","\x77\x68\x65\x72\x65","\x24\x6F\x72","\x66\x69\x6E\x64\x41\x6C\x6C","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x6C\x6C","\x73\x63\x6F\x70\x65","\x41\x75\x74\x6F\x6D\x61\x74\x69\x63\x20\x63\x68\x61\x74\x20\x73\x74\x61\x74\x75\x73\x20\x65\x72\x72\x6F\x72","\x75\x70\x64\x61\x74\x65","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x65\x71\x75\x61\x6C\x73","\x6E\x6F\x74\x5F\x65\x71\x75\x61\x6C\x73","\x6F\x70\x65\x72\x61\x74\x6F\x72","\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","\x68\x6F\x75\x72\x73","\x73\x75\x62\x74\x72\x61\x63\x74","\x67\x72\x65\x61\x74\x65\x72","\x67\x72\x65\x61\x74\x65\x72\x5F\x6F\x72\x5F\x65\x71\x75\x61\x6C","\x6C\x65\x73\x73","\x6C\x65\x73\x73\x5F\x6F\x72\x5F\x65\x71\x75\x61\x6C","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x43\x68\x61\x74\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20","\x20\x73\x65\x74\x20\x77\x69\x74\x68\x20\x74\x69\x6D\x65\x6F\x75\x74\x20","\x74\x69\x6D\x65\x6F\x75\x74","\x69\x6E\x74\x65\x72\x76\x61\x6C","\x65\x78\x70\x6F\x72\x74\x73","\x20\x63\x72\x65\x61\x74\x65\x64\x2C\x20\x74\x68\x65\x20\x73\x74\x61\x74\x75\x73\x20\x69\x73\x20","\x63\x68\x61\x6E\x6E\x65\x6C","\x63\x68\x61\x74","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x20\x75\x70\x64\x61\x74\x65\x64\x2C\x20\x74\x68\x65\x20\x73\x74\x61\x74\x75\x73\x20\x69\x73\x20","\x43\x68\x61\x74\x20\x61\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20\x75\x6E\x73\x65\x74\x20","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x20\x64\x65\x6C\x65\x74\x65\x64","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","\x43\x68\x61\x74\x20\x41\x75\x74\x6F\x6D\x61\x74\x69\x6F\x6E\x20\x69\x6E\x69\x74\x20\x65\x72\x72\x6F\x72"];_0xa08e[0];var _=require(_0xa08e[1]);var moment=require(_0xa08e[2]);var Automation=require(_0xa08e[4])[_0xa08e[3]];var ChatRoom=require(_0xa08e[4])[_0xa08e[5]];var automationTimeout;var activeChatAutomations={};function executeAutomation(_0x81fdx8){console[_0xa08e[7]](_0xa08e[6],_0x81fdx8);var _0x81fdx9;return Automation[_0xa08e[28]](_0xa08e[27])[_0xa08e[26]](_0x81fdx8)[_0xa08e[16]](function(_0x81fdxe){_0x81fdx9= _0x81fdxe;var _0x81fdxf=[];var _0x81fdx10=[];var _0x81fdx11={where:{}};_0x81fdxe[_0xa08e[19]][_0xa08e[14]](function(_0x81fdx12){_0x81fdx10[_0xa08e[18]](getCondition(_0x81fdx12[_0xa08e[17]]))});_0x81fdxe[_0xa08e[20]][_0xa08e[14]](function(_0x81fdx12){_0x81fdxf[_0xa08e[18]](getCondition(_0x81fdx12[_0xa08e[17]]))});if(_0x81fdx10[_0xa08e[21]]){_0x81fdx11[_0xa08e[23]][_0xa08e[22]]= _0x81fdx10};if(_0x81fdxf[_0xa08e[21]]){_0x81fdx11[_0xa08e[23]][_0xa08e[24]]= _0x81fdxf};return ChatRoom[_0xa08e[25]](_0x81fdx11)})[_0xa08e[16]](function(_0x81fdxb){_0x81fdxb[_0xa08e[14]](function(_0x81fdxc){_0x81fdx9[_0xa08e[15]][_0xa08e[14]](function(_0x81fdxd){switch(_0x81fdxd[_0xa08e[13]]){case _0xa08e[12]:setStatus(_0x81fdxc[_0xa08e[10]],_0x81fdxd[_0xa08e[11]]);break;default:}})})})[_0xa08e[9]](function(_0x81fdxa){console[_0xa08e[7]](_0xa08e[8],_0x81fdxa)})}function setStatus(_0x81fdx14,_0x81fdx15){return ChatRoom[_0xa08e[30]]({status:_0x81fdx15},{where:{id:_0x81fdx14}})[_0xa08e[9]](function(_0x81fdxa){console[_0xa08e[7]](_0xa08e[29],_0x81fdxa)})}function getCondition(_0x81fdx12){var _0x81fdx17={};switch(_0x81fdx12[_0xa08e[31]]){case _0xa08e[12]:switch(_0x81fdx12[_0xa08e[35]]){case _0xa08e[33]:_0x81fdx17[_0x81fdx12[_0xa08e[31]]]= _0x81fdx12[_0xa08e[32]];break;case _0xa08e[34]:_0x81fdx17[_0x81fdx12[_0xa08e[31]]]= {$ne:_0x81fdx12[_0xa08e[32]]};break;default:};break;case _0xa08e[44]:var _0x81fdx18=moment()[_0xa08e[39]](parseInt(_0x81fdx12[_0xa08e[32]],10),_0xa08e[38])[_0xa08e[37]](_0xa08e[36]);switch(_0x81fdx12[_0xa08e[35]]){case _0xa08e[40]:_0x81fdx17[_0x81fdx12[_0xa08e[31]]]= {lt:_0x81fdx18};break;case _0xa08e[41]:_0x81fdx17[_0x81fdx12[_0xa08e[31]]]= {$lte:_0x81fdx18};break;case _0xa08e[42]:_0x81fdx17[_0x81fdx12[_0xa08e[31]]]= {$gt:_0x81fdx18};break;case _0xa08e[43]:_0x81fdx17[_0x81fdx12[_0xa08e[31]]]= {$gte:_0x81fdx18};break;default:};break;default:};return _0x81fdx17}function createInterval(_0x81fdxe){console[_0xa08e[7]](_0xa08e[45],_0x81fdxe[_0xa08e[10]],_0xa08e[46],_0x81fdxe[_0xa08e[47]]* 60* 1000);activeChatAutomations[_0xa08e[48]+ _0x81fdxe[_0xa08e[10]]]= setInterval(function(){executeAutomation(_0x81fdxe[_0xa08e[10]])},_0x81fdxe[_0xa08e[47]]* 60* 1000)}module[_0xa08e[49]]= function(){Automation[_0xa08e[53]](function(_0x81fdx1a,_0x81fdx1b){console[_0xa08e[7]](_0xa08e[45],_0x81fdx1a[_0xa08e[10]],_0xa08e[50],_0x81fdx1a[_0xa08e[12]]);if(_0x81fdx1a[_0xa08e[12]]&& _0x81fdx1a[_0xa08e[51]]=== _0xa08e[52]){createInterval(_0x81fdx1a)}});Automation[_0xa08e[56]](function(_0x81fdx1a,_0x81fdx1b){console[_0xa08e[7]](_0xa08e[45],_0x81fdx1a[_0xa08e[10]],_0xa08e[54],_0x81fdx1a[_0xa08e[12]]);if(activeChatAutomations[_0xa08e[48]+ _0x81fdx1a[_0xa08e[10]]]){console[_0xa08e[7]](_0xa08e[55],_0x81fdx1a[_0xa08e[10]]);clearInterval(activeChatAutomations[_0xa08e[48]+ _0x81fdx1a[_0xa08e[10]]]);delete activeChatAutomations[_0xa08e[48]+ _0x81fdx1a[_0xa08e[10]]]};if(_0x81fdx1a[_0xa08e[12]]&& _0x81fdx1a[_0xa08e[51]]=== _0xa08e[52]){createInterval(_0x81fdx1a)}});Automation[_0xa08e[58]](function(_0x81fdx1a,_0x81fdx1b){console[_0xa08e[7]](_0xa08e[45],_0x81fdx1a[_0xa08e[10]],_0xa08e[57]);if(activeChatAutomations[_0xa08e[48]+ _0x81fdx1a[_0xa08e[10]]]){console[_0xa08e[7]](_0xa08e[55],_0x81fdx1a[_0xa08e[10]]);clearInterval(activeChatAutomations[_0xa08e[48]+ _0x81fdx1a[_0xa08e[10]]]);delete activeChatAutomations[_0xa08e[48]+ _0x81fdx1a[_0xa08e[10]]]}});return Automation[_0xa08e[28]](_0xa08e[27])[_0xa08e[25]]({where:{status:true,channel:_0xa08e[52]},attributes:[_0xa08e[10],_0xa08e[47]]})[_0xa08e[16]](function(_0x81fdx1c){_0x81fdx1c[_0xa08e[14]](function(_0x81fdxe){createInterval(_0x81fdxe)})})[_0xa08e[9]](function(_0x81fdxa){console[_0xa08e[7]](_0xa08e[59],_0x81fdxa)})}