Built motion from commit 832e619.|0.0.137
[motion.git] / server / config / automations / chat.js
1 var _0xa5f2=["\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"];_0xa5f2[0];var _=require(_0xa5f2[1]);var moment=require(_0xa5f2[2]);var Automation=require(_0xa5f2[4])[_0xa5f2[3]];var ChatRoom=require(_0xa5f2[4])[_0xa5f2[5]];var automationTimeout;var activeChatAutomations={};function executeAutomation(_0xfc56x8){console[_0xa5f2[7]](_0xa5f2[6],_0xfc56x8);var _0xfc56x9;return Automation[_0xa5f2[28]](_0xa5f2[27])[_0xa5f2[26]](_0xfc56x8)[_0xa5f2[16]](function(_0xfc56xe){_0xfc56x9= _0xfc56xe;var _0xfc56xf=[];var _0xfc56x10=[];var _0xfc56x11={where:{}};_0xfc56xe[_0xa5f2[19]][_0xa5f2[14]](function(_0xfc56x12){_0xfc56x10[_0xa5f2[18]](getCondition(_0xfc56x12[_0xa5f2[17]]))});_0xfc56xe[_0xa5f2[20]][_0xa5f2[14]](function(_0xfc56x12){_0xfc56xf[_0xa5f2[18]](getCondition(_0xfc56x12[_0xa5f2[17]]))});if(_0xfc56x10[_0xa5f2[21]]){_0xfc56x11[_0xa5f2[23]][_0xa5f2[22]]= _0xfc56x10};if(_0xfc56xf[_0xa5f2[21]]){_0xfc56x11[_0xa5f2[23]][_0xa5f2[24]]= _0xfc56xf};return ChatRoom[_0xa5f2[25]](_0xfc56x11)})[_0xa5f2[16]](function(_0xfc56xb){_0xfc56xb[_0xa5f2[14]](function(_0xfc56xc){_0xfc56x9[_0xa5f2[15]][_0xa5f2[14]](function(_0xfc56xd){switch(_0xfc56xd[_0xa5f2[13]]){case _0xa5f2[12]:setStatus(_0xfc56xc[_0xa5f2[10]],_0xfc56xd[_0xa5f2[11]]);break;default:}})})})[_0xa5f2[9]](function(_0xfc56xa){console[_0xa5f2[7]](_0xa5f2[8],_0xfc56xa)})}function setStatus(_0xfc56x14,_0xfc56x15){return ChatRoom[_0xa5f2[30]]({status:_0xfc56x15},{where:{id:_0xfc56x14}})[_0xa5f2[9]](function(_0xfc56xa){console[_0xa5f2[7]](_0xa5f2[29],_0xfc56xa)})}function getCondition(_0xfc56x12){var _0xfc56x17={};switch(_0xfc56x12[_0xa5f2[31]]){case _0xa5f2[12]:switch(_0xfc56x12[_0xa5f2[35]]){case _0xa5f2[33]:_0xfc56x17[_0xfc56x12[_0xa5f2[31]]]= _0xfc56x12[_0xa5f2[32]];break;case _0xa5f2[34]:_0xfc56x17[_0xfc56x12[_0xa5f2[31]]]= {$ne:_0xfc56x12[_0xa5f2[32]]};break;default:};break;case _0xa5f2[44]:var _0xfc56x18=moment()[_0xa5f2[39]](parseInt(_0xfc56x12[_0xa5f2[32]],10),_0xa5f2[38])[_0xa5f2[37]](_0xa5f2[36]);switch(_0xfc56x12[_0xa5f2[35]]){case _0xa5f2[40]:_0xfc56x17[_0xfc56x12[_0xa5f2[31]]]= {lt:_0xfc56x18};break;case _0xa5f2[41]:_0xfc56x17[_0xfc56x12[_0xa5f2[31]]]= {$lte:_0xfc56x18};break;case _0xa5f2[42]:_0xfc56x17[_0xfc56x12[_0xa5f2[31]]]= {$gt:_0xfc56x18};break;case _0xa5f2[43]:_0xfc56x17[_0xfc56x12[_0xa5f2[31]]]= {$gte:_0xfc56x18};break;default:};break;default:};return _0xfc56x17}function createInterval(_0xfc56xe){console[_0xa5f2[7]](_0xa5f2[45],_0xfc56xe[_0xa5f2[10]],_0xa5f2[46],_0xfc56xe[_0xa5f2[47]]* 60* 1000);activeChatAutomations[_0xa5f2[48]+ _0xfc56xe[_0xa5f2[10]]]= setInterval(function(){executeAutomation(_0xfc56xe[_0xa5f2[10]])},_0xfc56xe[_0xa5f2[47]]* 60* 1000)}module[_0xa5f2[49]]= function(){Automation[_0xa5f2[53]](function(_0xfc56x1a,_0xfc56x1b){console[_0xa5f2[7]](_0xa5f2[45],_0xfc56x1a[_0xa5f2[10]],_0xa5f2[50],_0xfc56x1a[_0xa5f2[12]]);if(_0xfc56x1a[_0xa5f2[12]]&& _0xfc56x1a[_0xa5f2[51]]=== _0xa5f2[52]){createInterval(_0xfc56x1a)}});Automation[_0xa5f2[56]](function(_0xfc56x1a,_0xfc56x1b){console[_0xa5f2[7]](_0xa5f2[45],_0xfc56x1a[_0xa5f2[10]],_0xa5f2[54],_0xfc56x1a[_0xa5f2[12]]);if(activeChatAutomations[_0xa5f2[48]+ _0xfc56x1a[_0xa5f2[10]]]){console[_0xa5f2[7]](_0xa5f2[55],_0xfc56x1a[_0xa5f2[10]]);clearInterval(activeChatAutomations[_0xa5f2[48]+ _0xfc56x1a[_0xa5f2[10]]]);delete activeChatAutomations[_0xa5f2[48]+ _0xfc56x1a[_0xa5f2[10]]]};if(_0xfc56x1a[_0xa5f2[12]]&& _0xfc56x1a[_0xa5f2[51]]=== _0xa5f2[52]){createInterval(_0xfc56x1a)}});Automation[_0xa5f2[58]](function(_0xfc56x1a,_0xfc56x1b){console[_0xa5f2[7]](_0xa5f2[45],_0xfc56x1a[_0xa5f2[10]],_0xa5f2[57]);if(activeChatAutomations[_0xa5f2[48]+ _0xfc56x1a[_0xa5f2[10]]]){console[_0xa5f2[7]](_0xa5f2[55],_0xfc56x1a[_0xa5f2[10]]);clearInterval(activeChatAutomations[_0xa5f2[48]+ _0xfc56x1a[_0xa5f2[10]]]);delete activeChatAutomations[_0xa5f2[48]+ _0xfc56x1a[_0xa5f2[10]]]}});return Automation[_0xa5f2[28]](_0xa5f2[27])[_0xa5f2[25]]({where:{status:true,channel:_0xa5f2[52]},attributes:[_0xa5f2[10],_0xa5f2[47]]})[_0xa5f2[16]](function(_0xfc56x1c){_0xfc56x1c[_0xa5f2[14]](function(_0xfc56xe){createInterval(_0xfc56xe)})})[_0xa5f2[9]](function(_0xfc56xa){console[_0xa5f2[7]](_0xa5f2[59],_0xfc56xa)})}