Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / routing / server / index.js
index c643b7e..82aa406 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5174=['faxQueues','whatsappQueues','chatQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','server','http','listen','log','RPC\x20listening\x20on\x20port:','lodash','path','jayson/promise','bluebird','uuid','../../../config/logger','routing','../rpc/chatQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','../lib/rule-engine','format','%s.%s.%s','isNil','IntervalId','Intervals','interval','rules','channel','message','interaction','applications','isArray','length','join','app','toLowerCase','autoreply','appdata','split','push','dialogflow','slice','amazonlex','tag','TagId','./interval','condition','./applications/','Push\x20new\x20rule','on\x20interval','intervals','error','Please\x20create\x20a\x20new\x20file\x20under','execute','info','Applications\x20executed','stringify','matchPath','emit','complete','No\x20applications\x20to\x20execute','stack','routing\x20is\x20empty','end','QueueReport','UserId','catch','message\x20is\x20empty','agent','agents','busy','busyQueue','hasOwnProperty','capacity','CurrentCapacity','values','chatQueues','available','name','paused','waiting','mailQueues','loggedIn','openchannelQueues','smsQueues'];(function(_0x39bfb6,_0x4272c8){var _0x23fef9=function(_0x5f83c1){while(--_0x5f83c1){_0x39bfb6['push'](_0x39bfb6['shift']());}};_0x23fef9(++_0x4272c8);}(_0x5174,0x117));var _0x4517=function(_0xbfddf,_0x18f549){_0xbfddf=_0xbfddf-0x0;var _0x565f9b=_0x5174[_0xbfddf];return _0x565f9b;};'use strict';var _=require(_0x4517('0x0'));var util=require('util');var path=require(_0x4517('0x1'));var fs=require('fs');var jayson=require(_0x4517('0x2'));var BPromise=require(_0x4517('0x3'));var uuid=require(_0x4517('0x4'));var config=require('../../../config/environment');var logger=require(_0x4517('0x5'))(_0x4517('0x6'));var rpc={'openchannelQueueReport':require('../rpc/openchannelQueueReport'),'mailQueueReport':require('../rpc/mailQueueReport'),'chatQueueReport':require(_0x4517('0x7')),'smsQueueReport':require(_0x4517('0x8')),'faxQueueReport':require(_0x4517('0x9')),'whatsappQueueReport':require(_0x4517('0xa'))};var RuleEngine=require(_0x4517('0xb'));function getId(_0x10e198,_0x4aa549,_0x3346f2){return util[_0x4517('0xc')](_0x4517('0xd'),_0x10e198,_0x4aa549||0x0,_0x3346f2||0x0);}function getIntervals(_0x32c4da,_0x5d38bf){var _0x15c02c=[];if(!_[_0x4517('0xe')](_0x5d38bf[_0x4517('0xf')])&&!_[_0x4517('0xe')](_0x32c4da[_0x5d38bf['IntervalId']])&&!_['isNil'](_0x32c4da[_0x5d38bf[_0x4517('0xf')]]['Intervals'])){_0x15c02c=_['map'](_0x32c4da[_0x5d38bf[_0x4517('0xf')]][_0x4517('0x10')],_0x4517('0x11'));}else if(!_[_0x4517('0xe')](_0x5d38bf[_0x4517('0x11')])){_0x15c02c=[_0x5d38bf[_0x4517('0x11')]];}return _0x15c02c;}exports['listen']=function(_0x9947d1){_0x9947d1[_0x4517('0x12')]={};return new BPromise(function(_0x1ec378,_0xb0b1cb){var _0x582caf={'Start':function(_0x1fdafa){var _0x5a1f52=this;return new Promise(function(_0x11b4fa,_0x151125){if(_0x1fdafa){try{var _0x2684eb=[];var _0xc699d1=getId(_0x1fdafa[_0x4517('0x13')],_0x1fdafa['message']?_0x1fdafa[_0x4517('0x14')]['id']:0x0,_0x1fdafa[_0x4517('0x15')]?_0x1fdafa[_0x4517('0x15')]['id']:0x0);if(_0x1fdafa[_0x4517('0x16')]&&_[_0x4517('0x17')](_0x1fdafa[_0x4517('0x16')])&&_0x1fdafa[_0x4517('0x16')][_0x4517('0x18')]){for(var _0x436aba=0x0;_0x436aba<_0x1fdafa[_0x4517('0x16')][_0x4517('0x18')];_0x436aba+=0x1){var _0x546134=_0x1fdafa[_0x4517('0x16')][_0x436aba];if(fs['existsSync'](path[_0x4517('0x19')](__dirname,'applications',_0x546134[_0x4517('0x1a')]+'.js'))){var _0x54f792=[];switch(_0x546134[_0x4517('0x1a')][_0x4517('0x1b')]()){case _0x4517('0x1c'):var _0x286ff8=_0x546134[_0x4517('0x1d')][_0x4517('0x1e')](',');_0x54f792[_0x4517('0x1f')](_0x286ff8[0x0]);_0x54f792['push'](_0x286ff8['slice'](0x1,_0x286ff8[_0x4517('0x18')])['join'](','));break;case _0x4517('0x20'):var _0x3b4867=_0x546134['appdata'][_0x4517('0x1e')](',');_0x54f792[_0x4517('0x1f')](_0x3b4867[0x0]);_0x54f792[_0x4517('0x1f')](_0x3b4867[0x1]);_0x54f792[_0x4517('0x1f')](_0x3b4867[_0x4517('0x21')](0x2,_0x3b4867['length'])[_0x4517('0x19')](','));break;case _0x4517('0x22'):var _0x4c602e=_0x546134['appdata']['split'](',');_0x54f792['push'](_0x4c602e[0x0]);_0x54f792['push'](_0x4c602e[0x1]);_0x54f792[_0x4517('0x1f')](_0x4c602e[0x2]);_0x54f792[_0x4517('0x1f')](_0x4c602e[0x3]);_0x54f792[_0x4517('0x1f')](_0x4c602e[_0x4517('0x21')](0x4,_0x4c602e[_0x4517('0x18')])[_0x4517('0x19')](','));break;case _0x4517('0x14'):_0x54f792[_0x4517('0x1f')](_0x546134[_0x4517('0x1d')]);break;case _0x4517('0x23'):_0x54f792[_0x4517('0x1f')](_0x546134[_0x4517('0x24')]);_0x54f792['push'](_0x546134[_0x4517('0x1d')]);break;default:_0x54f792=_[_0x4517('0xe')](_0x546134[_0x4517('0x1d')])?[]:_0x546134[_0x4517('0x1d')][_0x4517('0x1e')](',');}var _0x24ebdf={'id':util[_0x4517('0xc')]('%s:%s:%s',_0xc699d1,_0x546134['id'],_0x546134[_0x4517('0x1a')]),'condition':require(_0x4517('0x25'))[_0x4517('0x26')](_0xc699d1,getIntervals(_0x9947d1['intervals'],_0x546134),_0x9947d1),'consequence':require(_0x4517('0x27')+_0x546134['app'])['consequence'](_0xc699d1,_0x54f792,_0x9947d1,_0x1fdafa),'p':_0x546134['priority']||0x0};logger['info'](_0x4517('0x28'),_0x24ebdf['id'],_0x4517('0x29'),getIntervals(_0x9947d1[_0x4517('0x2a')],_0x546134)[_0x4517('0x19')]('\x20|\x20'));_0x2684eb[_0x4517('0x1f')](_0x24ebdf);}else{logger[_0x4517('0x2b')](_0x4517('0x2c'),path[_0x4517('0x19')](__dirname,_0x4517('0x16'),_0x546134['app']+'.js'));}}_0x9947d1['rules'][_0xc699d1]=new RuleEngine(_0x2684eb);_0x9947d1[_0x4517('0x12')][_0xc699d1][_0x4517('0x2d')](_0x1fdafa,function(_0x477271){logger[_0x4517('0x2e')](_0x4517('0x2f'),JSON[_0x4517('0x30')](_0x477271[_0x4517('0x31')]));if(_0x9947d1['rules'][_0xc699d1]){_0x9947d1[_0x4517('0x12')][_0xc699d1][_0x4517('0x32')](_0x4517('0x33'));}});return _0x11b4fa({'code':0xc8,'message':_0x1fdafa});}else{logger['info'](_0x4517('0x34'));return _0x11b4fa({'code':0xc8,'message':_0x1fdafa});}}catch(_0x5a1153){logger[_0x4517('0x2b')](_0x5a1153[_0x4517('0x35')]);return _0x151125(_0x5a1f52[_0x4517('0x2b')](0x1f4,_0x5a1153));}}return _0x151125(_0x4517('0x36'));});},'AcceptMessage':function(_0x405a57){var _0x531187=this;return new Promise(function(_0x145fb0,_0x4ecb0f){if(_0x405a57[_0x4517('0x14')]&&_0x405a57[_0x4517('0x14')]['id']){try{var _0x52b1de=getId(_0x405a57[_0x4517('0x13')],_0x405a57[_0x4517('0x14')]?_0x405a57[_0x4517('0x14')]['id']:0x0,_0x405a57[_0x4517('0x15')]?_0x405a57['interaction']['id']:0x0);if(_0x9947d1[_0x4517('0x12')][_0x52b1de]){_0x9947d1[_0x4517('0x12')][_0x52b1de][_0x4517('0x32')](_0x4517('0x37'));if(rpc[_0x405a57[_0x4517('0x13')]+_0x4517('0x38')]){rpc[_0x405a57[_0x4517('0x13')]+'QueueReport']['update'](_0x52b1de,{'UserId':_0x405a57[_0x4517('0x14')][_0x4517('0x39')]})[_0x4517('0x3a')](function(_0x2ad16b){logger[_0x4517('0x2b')]('error\x20update\x20queue\x20report');});}}return _0x145fb0({'code':0xc8,'message':_0x405a57});}catch(_0x22110d){logger[_0x4517('0x2b')](_0x22110d[_0x4517('0x35')]);return _0x4ecb0f(_0x531187[_0x4517('0x2b')](0x1f4,_0x22110d));}}logger[_0x4517('0x2b')](_0x4517('0x3b'));return _0x4ecb0f(_0x531187[_0x4517('0x2b')](0x1f4,_0x4517('0x3b')));});},'RejectMessage':function(_0x43e43b){var _0x4b21be=this;return new Promise(function(_0x52e1c5,_0x3dc2f2){if(_0x43e43b[_0x4517('0x3c')]&&_0x43e43b['agent']['id']){try{if(_0x9947d1[_0x4517('0x3d')][_0x43e43b['agent']['id']]){_0x9947d1[_0x4517('0x3d')][_0x43e43b['agent']['id']][_0x4517('0x3e')]=![];_0x9947d1['agents'][_0x43e43b[_0x4517('0x3c')]['id']][_0x4517('0x3f')]=undefined;}return _0x52e1c5({'code':0xc8,'message':_0x43e43b});}catch(_0x10bf38){logger[_0x4517('0x2b')](_0x10bf38[_0x4517('0x35')]);return _0x3dc2f2(_0x4b21be[_0x4517('0x2b')](0x1f4,_0x10bf38));}}logger['error']('message\x20is\x20empty');return _0x3dc2f2(_0x4b21be[_0x4517('0x2b')](0x1f4,_0x4517('0x3b')));});},'AbandonInteraction':function(_0x112f94){var _0x5792f2=this;return new Promise(function(_0x30f5f5,_0x15a81b){if(_0x112f94['channel']&&_0x112f94[_0x4517('0x15')]&&_0x112f94[_0x4517('0x15')]['id']){try{var _0x44e88a=getId(_0x112f94[_0x4517('0x13')],_0x112f94['message']?_0x112f94['message']['id']:0x0,_0x112f94[_0x4517('0x15')]?_0x112f94[_0x4517('0x15')]['id']:0x0);if(_0x9947d1['rules'][_0x44e88a]){_0x9947d1[_0x4517('0x12')][_0x44e88a][_0x4517('0x32')](_0x4517('0x37'));}return _0x30f5f5({'code':0xc8,'message':_0x112f94});}catch(_0x3e836d){logger[_0x4517('0x2b')](_0x3e836d['stack']);return _0x15a81b(_0x5792f2[_0x4517('0x2b')](0x1f4,_0x3e836d));}}logger[_0x4517('0x2b')]('message\x20is\x20empty');return _0x15a81b(_0x5792f2[_0x4517('0x2b')](0x1f4,_0x4517('0x3b')));});},'AgentCapacity':function(_0x75186e){var _0x5f4dae=this;return new Promise(function(_0x133728,_0x9f6129){if(_0x9947d1[_0x4517('0x3d')][_0x4517('0x40')](_0x75186e['id'])){for(var _0x38265a in _0x75186e[_0x4517('0x41')]){if(_0x75186e[_0x4517('0x41')][_0x4517('0x40')](_0x38265a)){if(_0x9947d1['agents'][_0x75186e['id']][_0x4517('0x40')](_0x38265a+_0x4517('0x42'))){_0x9947d1['agents'][_0x75186e['id']][_0x38265a+'CurrentCapacity']=parseInt(_0x75186e[_0x4517('0x41')][_0x38265a],0xa);}}}_0x9947d1[_0x4517('0x3d')][_0x75186e['id']]['updateRealtime']();return _0x133728({'code':0xc8,'message':_0x9947d1[_0x4517('0x3d')][_0x75186e['id']]});}else{return _0x9f6129(_0x5f4dae[_0x4517('0x2b')](0x1f4,'agent\x20not\x20found'));}});},'Agents':function(_0x5d67f3){return new Promise(function(_0x4e9d86,_0x283756){var _0x3627c4=_[_0x4517('0x43')](_0x9947d1[_0x4517('0x3d')]);_0x4e9d86({'count':_0x3627c4[_0x4517('0x18')],'rows':_0x3627c4});});},'ChatQueues':function(_0x1e03c7){return new Promise(function(_0x4ad805,_0x546b77){var _0x1bc21e=[];for(var _0x576d85 in _0x9947d1['chatQueues']){if(_0x9947d1[_0x4517('0x44')][_0x4517('0x40')](_0x576d85)){var _0x2bd4f8=_0x9947d1[_0x4517('0x44')][_0x576d85];var _0x59d39a={'id':_0x2bd4f8['id'],'available':_0x2bd4f8[_0x4517('0x45')],'loggedIn':_0x2bd4f8['loggedIn'],'name':_0x2bd4f8[_0x4517('0x46')],'paused':_0x2bd4f8[_0x4517('0x47')],'waiting':_0x2bd4f8[_0x4517('0x48')]};_0x1bc21e[_0x4517('0x1f')](_0x59d39a);}}_0x4ad805({'count':_0x1bc21e['length'],'rows':_0x1bc21e});});},'MailQueues':function(_0x330e5f){return new Promise(function(_0x53b1f1,_0x68e042){var _0x54e159=[];for(var _0x389f73 in _0x9947d1['mailQueues']){if(_0x9947d1['mailQueues'][_0x4517('0x40')](_0x389f73)){var _0x212be4=_0x9947d1[_0x4517('0x49')][_0x389f73];var _0x5a6f6f={'id':_0x212be4['id'],'available':_0x212be4['available'],'loggedIn':_0x212be4[_0x4517('0x4a')],'name':_0x212be4[_0x4517('0x46')],'paused':_0x212be4['paused'],'waiting':_0x212be4['waiting']};_0x54e159[_0x4517('0x1f')](_0x5a6f6f);}}_0x53b1f1({'count':_0x54e159['length'],'rows':_0x54e159});});},'OpenchannelQueues':function(_0x5251cb){return new Promise(function(_0x840c7e,_0x3fb806){var _0x5854c4=[];for(var _0x465a08 in _0x9947d1[_0x4517('0x4b')]){if(_0x9947d1[_0x4517('0x4b')][_0x4517('0x40')](_0x465a08)){var _0x5da145=_0x9947d1[_0x4517('0x4b')][_0x465a08];var _0x2bdcc7={'id':_0x5da145['id'],'available':_0x5da145['available'],'loggedIn':_0x5da145['loggedIn'],'name':_0x5da145[_0x4517('0x46')],'paused':_0x5da145[_0x4517('0x47')],'waiting':_0x5da145[_0x4517('0x48')]};_0x5854c4['push'](_0x2bdcc7);}}_0x840c7e({'count':_0x5854c4[_0x4517('0x18')],'rows':_0x5854c4});});},'SmsQueues':function(_0x1402fa){return new Promise(function(_0x4d3147,_0x26b754){var _0x1cef5d=[];for(var _0x4a5fd1 in _0x9947d1['smsQueues']){if(_0x9947d1['smsQueues'][_0x4517('0x40')](_0x4a5fd1)){var _0x4a82e3=_0x9947d1[_0x4517('0x4c')][_0x4a5fd1];var _0x3cfcc4={'id':_0x4a82e3['id'],'available':_0x4a82e3[_0x4517('0x45')],'loggedIn':_0x4a82e3['loggedIn'],'name':_0x4a82e3[_0x4517('0x46')],'paused':_0x4a82e3['paused'],'waiting':_0x4a82e3[_0x4517('0x48')]};_0x1cef5d[_0x4517('0x1f')](_0x3cfcc4);}}_0x4d3147({'count':_0x1cef5d[_0x4517('0x18')],'rows':_0x1cef5d});});},'FaxQueues':function(_0x4c9300){return new Promise(function(_0x2479a4,_0x596309){var _0x4b3925=[];for(var _0x3d4fbd in _0x9947d1[_0x4517('0x4d')]){if(_0x9947d1[_0x4517('0x4d')]['hasOwnProperty'](_0x3d4fbd)){var _0x2a5871=_0x9947d1[_0x4517('0x4d')][_0x3d4fbd];var _0x929f47={'id':_0x2a5871['id'],'available':_0x2a5871['available'],'loggedIn':_0x2a5871[_0x4517('0x4a')],'name':_0x2a5871[_0x4517('0x46')],'paused':_0x2a5871['paused'],'waiting':_0x2a5871['waiting']};_0x4b3925[_0x4517('0x1f')](_0x929f47);}}_0x2479a4({'count':_0x4b3925[_0x4517('0x18')],'rows':_0x4b3925});});},'WhatsappQueues':function(_0x46c6f6){return new Promise(function(_0x372461,_0xfedf29){var _0x31c99c=[];for(var _0x5a3fb4 in _0x9947d1[_0x4517('0x4e')]){if(_0x9947d1[_0x4517('0x4e')][_0x4517('0x40')](_0x5a3fb4)){var _0x4f30b0=_0x9947d1['whatsappQueues'][_0x5a3fb4];var _0x40bd1b={'id':_0x4f30b0['id'],'available':_0x4f30b0[_0x4517('0x45')],'loggedIn':_0x4f30b0[_0x4517('0x4a')],'name':_0x4f30b0['name'],'paused':_0x4f30b0['paused'],'waiting':_0x4f30b0[_0x4517('0x48')]};_0x31c99c[_0x4517('0x1f')](_0x40bd1b);}}_0x372461({'count':_0x31c99c['length'],'rows':_0x31c99c});});},'ChatQueuesWaitingInteractions':function(_0x42217b){return new Promise(function(_0x409635,_0x2ce245){var _0x1cf342=_[_0x4517('0x43')](_0x9947d1[_0x4517('0x4f')]);_0x409635({'count':_0x1cf342['length'],'rows':_0x1cf342});});},'MailQueuesWaitingInteractions':function(_0x3abf1a){return new Promise(function(_0x1d0902,_0x3f265e){var _0x478b19=_[_0x4517('0x43')](_0x9947d1['mailQueuesWaitingInteractions']);_0x1d0902({'count':_0x478b19['length'],'rows':_0x478b19});});},'OpenchannelQueuesWaitingInteractions':function(_0x4506fa){return new Promise(function(_0x45f6c0,_0x7b627f){var _0x1b6ddc=_[_0x4517('0x43')](_0x9947d1[_0x4517('0x50')]);_0x45f6c0({'count':_0x1b6ddc[_0x4517('0x18')],'rows':_0x1b6ddc});});},'SmsQueuesWaitingInteractions':function(_0x322bef){return new Promise(function(_0x310310,_0x1a5399){var _0xed74fe=_[_0x4517('0x43')](_0x9947d1[_0x4517('0x51')]);_0x310310({'count':_0xed74fe[_0x4517('0x18')],'rows':_0xed74fe});});},'FaxQueuesWaitingInteractions':function(_0x4376d8){return new Promise(function(_0x40fd9b,_0x2f8236){var _0x167f2d=_[_0x4517('0x43')](_0x9947d1[_0x4517('0x52')]);_0x40fd9b({'count':_0x167f2d[_0x4517('0x18')],'rows':_0x167f2d});});},'WhatsappQueuesWaitingInteractions':function(_0x4444f2){return new Promise(function(_0x582056,_0x9b235d){var _0xe67e81=_['values'](_0x9947d1[_0x4517('0x53')]);_0x582056({'count':_0xe67e81['length'],'rows':_0xe67e81});});}};var _0x19715c=jayson[_0x4517('0x54')](_0x582caf)[_0x4517('0x55')]();_0x19715c['on'](_0x4517('0x2b'),function(_0x5553c0){logger[_0x4517('0x2b')](JSON['stringify'](_0x5553c0));return _0xb0b1cb(_0x5553c0);});_0x19715c[_0x4517('0x56')](0x232c,'127.0.0.1',function(){console[_0x4517('0x57')]('Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!',0x232c);return _0x1ec378(_0x4517('0x58')+0x232c);});});};
\ No newline at end of file
+var _0xff3f=['autoreply','appdata','split','push','slice','amazonlex','tag','TagId','format','%s:%s:%s','./interval','condition','intervals','./applications/','consequence','info','Push\x20new\x20rule','on\x20interval','\x20|\x20','error','execute','Applications\x20executed','stringify','matchPath','emit','complete','No\x20applications\x20to\x20execute','stack','routing\x20is\x20empty','interaction','end','QueueReport','update','UserId','catch','error\x20update\x20queue\x20report','message\x20is\x20empty','agent','agents','busy','busyQueue','hasOwnProperty','capacity','CurrentCapacity','updateRealtime','agent\x20not\x20found','chatQueues','available','loggedIn','name','paused','waiting','mailQueues','openchannelQueues','smsQueues','faxQueues','whatsappQueues','chatQueuesWaitingInteractions','values','mailQueuesWaitingInteractions','openchannelQueuesWaitingInteractions','smsQueuesWaitingInteractions','faxQueuesWaitingInteractions','whatsappQueuesWaitingInteractions','server','Routing\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','lodash','util','bluebird','uuid','../../../config/logger','routing','../rpc/mailQueueReport','../rpc/chatQueueReport','../rpc/smsQueueReport','../rpc/faxQueueReport','../rpc/whatsappQueueReport','../lib/rule-engine','%s.%s.%s','IntervalId','isNil','map','interval','listen','rules','channel','message','applications','isArray','length','existsSync','join','app','.js','toLowerCase'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xff3f,0xa3));var _0xfff3=function(_0x48999d,_0x1e02cb){_0x48999d=_0x48999d-0x0;var _0x1ad0d1=_0xff3f[_0x48999d];return _0x1ad0d1;};'use strict';var _=require(_0xfff3('0x0'));var util=require(_0xfff3('0x1'));var path=require('path');var fs=require('fs');var jayson=require('jayson/promise');var BPromise=require(_0xfff3('0x2'));var uuid=require(_0xfff3('0x3'));var config=require('../../../config/environment');var logger=require(_0xfff3('0x4'))(_0xfff3('0x5'));var rpc={'openchannelQueueReport':require('../rpc/openchannelQueueReport'),'mailQueueReport':require(_0xfff3('0x6')),'chatQueueReport':require(_0xfff3('0x7')),'smsQueueReport':require(_0xfff3('0x8')),'faxQueueReport':require(_0xfff3('0x9')),'whatsappQueueReport':require(_0xfff3('0xa'))};var RuleEngine=require(_0xfff3('0xb'));function getId(_0x586465,_0x225324,_0x26c86e){return util['format'](_0xfff3('0xc'),_0x586465,_0x225324||0x0,_0x26c86e||0x0);}function getIntervals(_0x1c8727,_0x19be36){var _0x5ba262=[];if(!_['isNil'](_0x19be36[_0xfff3('0xd')])&&!_[_0xfff3('0xe')](_0x1c8727[_0x19be36[_0xfff3('0xd')]])&&!_[_0xfff3('0xe')](_0x1c8727[_0x19be36[_0xfff3('0xd')]]['Intervals'])){_0x5ba262=_[_0xfff3('0xf')](_0x1c8727[_0x19be36[_0xfff3('0xd')]]['Intervals'],'interval');}else if(!_[_0xfff3('0xe')](_0x19be36['interval'])){_0x5ba262=[_0x19be36[_0xfff3('0x10')]];}return _0x5ba262;}exports[_0xfff3('0x11')]=function(_0xe9b1a0){_0xe9b1a0[_0xfff3('0x12')]={};return new BPromise(function(_0x3ac767,_0x5f4cbe){var _0x1b2456={'Start':function(_0x37b995){var _0x4a2067=this;return new Promise(function(_0x214ad2,_0x2a6e70){if(_0x37b995){try{var _0xafb133=[];var _0x3ac778=getId(_0x37b995[_0xfff3('0x13')],_0x37b995[_0xfff3('0x14')]?_0x37b995[_0xfff3('0x14')]['id']:0x0,_0x37b995['interaction']?_0x37b995['interaction']['id']:0x0);if(_0x37b995[_0xfff3('0x15')]&&_[_0xfff3('0x16')](_0x37b995[_0xfff3('0x15')])&&_0x37b995[_0xfff3('0x15')][_0xfff3('0x17')]){for(var _0x3cc56e=0x0;_0x3cc56e<_0x37b995[_0xfff3('0x15')]['length'];_0x3cc56e+=0x1){var _0x43f8e1=_0x37b995[_0xfff3('0x15')][_0x3cc56e];if(fs[_0xfff3('0x18')](path[_0xfff3('0x19')](__dirname,_0xfff3('0x15'),_0x43f8e1[_0xfff3('0x1a')]+_0xfff3('0x1b')))){var _0x47fc56=[];switch(_0x43f8e1[_0xfff3('0x1a')][_0xfff3('0x1c')]()){case _0xfff3('0x1d'):var _0x1f596c=_0x43f8e1[_0xfff3('0x1e')][_0xfff3('0x1f')](',');_0x47fc56[_0xfff3('0x20')](_0x1f596c[0x0]);_0x47fc56['push'](_0x1f596c[_0xfff3('0x21')](0x1,_0x1f596c[_0xfff3('0x17')])[_0xfff3('0x19')](','));break;case'dialogflow':var _0x43042d=_0x43f8e1[_0xfff3('0x1e')]['split'](',');_0x47fc56[_0xfff3('0x20')](_0x43042d[0x0]);_0x47fc56[_0xfff3('0x20')](_0x43042d[0x1]);_0x47fc56[_0xfff3('0x20')](_0x43042d['slice'](0x2,_0x43042d[_0xfff3('0x17')])[_0xfff3('0x19')](','));break;case _0xfff3('0x22'):var _0xb4a8df=_0x43f8e1['appdata'][_0xfff3('0x1f')](',');_0x47fc56[_0xfff3('0x20')](_0xb4a8df[0x0]);_0x47fc56[_0xfff3('0x20')](_0xb4a8df[0x1]);_0x47fc56['push'](_0xb4a8df[0x2]);_0x47fc56[_0xfff3('0x20')](_0xb4a8df[0x3]);_0x47fc56['push'](_0xb4a8df[_0xfff3('0x21')](0x4,_0xb4a8df[_0xfff3('0x17')])['join'](','));break;case'message':_0x47fc56[_0xfff3('0x20')](_0x43f8e1[_0xfff3('0x1e')]);break;case _0xfff3('0x23'):_0x47fc56[_0xfff3('0x20')](_0x43f8e1[_0xfff3('0x24')]);_0x47fc56[_0xfff3('0x20')](_0x43f8e1[_0xfff3('0x1e')]);break;default:_0x47fc56=_[_0xfff3('0xe')](_0x43f8e1[_0xfff3('0x1e')])?[]:_0x43f8e1[_0xfff3('0x1e')][_0xfff3('0x1f')](',');}var _0x2e8e07={'id':util[_0xfff3('0x25')](_0xfff3('0x26'),_0x3ac778,_0x43f8e1['id'],_0x43f8e1[_0xfff3('0x1a')]),'condition':require(_0xfff3('0x27'))[_0xfff3('0x28')](_0x3ac778,getIntervals(_0xe9b1a0[_0xfff3('0x29')],_0x43f8e1),_0xe9b1a0),'consequence':require(_0xfff3('0x2a')+_0x43f8e1['app'])[_0xfff3('0x2b')](_0x3ac778,_0x47fc56,_0xe9b1a0,_0x37b995),'p':_0x43f8e1['priority']||0x0};logger[_0xfff3('0x2c')](_0xfff3('0x2d'),_0x2e8e07['id'],_0xfff3('0x2e'),getIntervals(_0xe9b1a0['intervals'],_0x43f8e1)['join'](_0xfff3('0x2f')));_0xafb133[_0xfff3('0x20')](_0x2e8e07);}else{logger[_0xfff3('0x30')]('Please\x20create\x20a\x20new\x20file\x20under',path[_0xfff3('0x19')](__dirname,_0xfff3('0x15'),_0x43f8e1[_0xfff3('0x1a')]+_0xfff3('0x1b')));}}_0xe9b1a0[_0xfff3('0x12')][_0x3ac778]=new RuleEngine(_0xafb133);_0xe9b1a0[_0xfff3('0x12')][_0x3ac778][_0xfff3('0x31')](_0x37b995,function(_0x3d09ff){logger[_0xfff3('0x2c')](_0xfff3('0x32'),JSON[_0xfff3('0x33')](_0x3d09ff[_0xfff3('0x34')]));if(_0xe9b1a0[_0xfff3('0x12')][_0x3ac778]){_0xe9b1a0[_0xfff3('0x12')][_0x3ac778][_0xfff3('0x35')](_0xfff3('0x36'));}});return _0x214ad2({'code':0xc8,'message':_0x37b995});}else{logger['info'](_0xfff3('0x37'));return _0x214ad2({'code':0xc8,'message':_0x37b995});}}catch(_0x140650){logger[_0xfff3('0x30')](_0x140650[_0xfff3('0x38')]);return _0x2a6e70(_0x4a2067[_0xfff3('0x30')](0x1f4,_0x140650));}}return _0x2a6e70(_0xfff3('0x39'));});},'AcceptMessage':function(_0x322787){var _0x2e0fcc=this;return new Promise(function(_0x352250,_0x2a437e){if(_0x322787[_0xfff3('0x14')]&&_0x322787[_0xfff3('0x14')]['id']){try{var _0xdc743b=getId(_0x322787[_0xfff3('0x13')],_0x322787['message']?_0x322787[_0xfff3('0x14')]['id']:0x0,_0x322787[_0xfff3('0x3a')]?_0x322787[_0xfff3('0x3a')]['id']:0x0);if(_0xe9b1a0['rules'][_0xdc743b]){_0xe9b1a0[_0xfff3('0x12')][_0xdc743b][_0xfff3('0x35')](_0xfff3('0x3b'));if(rpc[_0x322787[_0xfff3('0x13')]+_0xfff3('0x3c')]){rpc[_0x322787[_0xfff3('0x13')]+_0xfff3('0x3c')][_0xfff3('0x3d')](_0xdc743b,{'UserId':_0x322787[_0xfff3('0x14')][_0xfff3('0x3e')]})[_0xfff3('0x3f')](function(_0x34ca6d){logger[_0xfff3('0x30')](_0xfff3('0x40'));});}}return _0x352250({'code':0xc8,'message':_0x322787});}catch(_0x2a6149){logger[_0xfff3('0x30')](_0x2a6149[_0xfff3('0x38')]);return _0x2a437e(_0x2e0fcc[_0xfff3('0x30')](0x1f4,_0x2a6149));}}logger[_0xfff3('0x30')](_0xfff3('0x41'));return _0x2a437e(_0x2e0fcc['error'](0x1f4,_0xfff3('0x41')));});},'RejectMessage':function(_0x5efa0e){var _0x4cce1d=this;return new Promise(function(_0x330a96,_0x3ea17b){if(_0x5efa0e[_0xfff3('0x42')]&&_0x5efa0e[_0xfff3('0x42')]['id']){try{if(_0xe9b1a0[_0xfff3('0x43')][_0x5efa0e[_0xfff3('0x42')]['id']]){_0xe9b1a0['agents'][_0x5efa0e[_0xfff3('0x42')]['id']][_0xfff3('0x44')]=![];_0xe9b1a0['agents'][_0x5efa0e['agent']['id']][_0xfff3('0x45')]=undefined;}return _0x330a96({'code':0xc8,'message':_0x5efa0e});}catch(_0x34acc6){logger['error'](_0x34acc6['stack']);return _0x3ea17b(_0x4cce1d[_0xfff3('0x30')](0x1f4,_0x34acc6));}}logger[_0xfff3('0x30')]('message\x20is\x20empty');return _0x3ea17b(_0x4cce1d[_0xfff3('0x30')](0x1f4,_0xfff3('0x41')));});},'AbandonInteraction':function(_0xe68fad){var _0x50559c=this;return new Promise(function(_0x44d7f6,_0x5ed990){if(_0xe68fad[_0xfff3('0x13')]&&_0xe68fad[_0xfff3('0x3a')]&&_0xe68fad['interaction']['id']){try{var _0x46e90c=getId(_0xe68fad[_0xfff3('0x13')],_0xe68fad[_0xfff3('0x14')]?_0xe68fad[_0xfff3('0x14')]['id']:0x0,_0xe68fad[_0xfff3('0x3a')]?_0xe68fad['interaction']['id']:0x0);if(_0xe9b1a0['rules'][_0x46e90c]){_0xe9b1a0[_0xfff3('0x12')][_0x46e90c][_0xfff3('0x35')](_0xfff3('0x3b'));}return _0x44d7f6({'code':0xc8,'message':_0xe68fad});}catch(_0x4edeb0){logger['error'](_0x4edeb0['stack']);return _0x5ed990(_0x50559c['error'](0x1f4,_0x4edeb0));}}logger[_0xfff3('0x30')](_0xfff3('0x41'));return _0x5ed990(_0x50559c[_0xfff3('0x30')](0x1f4,_0xfff3('0x41')));});},'AgentCapacity':function(_0x1f7cb6){var _0x438694=this;return new Promise(function(_0x52da61,_0x248424){if(_0xe9b1a0['agents'][_0xfff3('0x46')](_0x1f7cb6['id'])){for(var _0x486eb3 in _0x1f7cb6[_0xfff3('0x47')]){if(_0x1f7cb6[_0xfff3('0x47')][_0xfff3('0x46')](_0x486eb3)){if(_0xe9b1a0[_0xfff3('0x43')][_0x1f7cb6['id']][_0xfff3('0x46')](_0x486eb3+'CurrentCapacity')){_0xe9b1a0[_0xfff3('0x43')][_0x1f7cb6['id']][_0x486eb3+_0xfff3('0x48')]=parseInt(_0x1f7cb6[_0xfff3('0x47')][_0x486eb3],0xa);}}}_0xe9b1a0[_0xfff3('0x43')][_0x1f7cb6['id']][_0xfff3('0x49')]();return _0x52da61({'code':0xc8,'message':_0xe9b1a0[_0xfff3('0x43')][_0x1f7cb6['id']]});}else{return _0x248424(_0x438694[_0xfff3('0x30')](0x1f4,_0xfff3('0x4a')));}});},'Agents':function(_0x4f18b2){return new Promise(function(_0x5b6d85,_0x4f56e6){var _0x3cc7bf=_['values'](_0xe9b1a0[_0xfff3('0x43')]);_0x5b6d85({'count':_0x3cc7bf[_0xfff3('0x17')],'rows':_0x3cc7bf});});},'ChatQueues':function(_0x3e05a9){return new Promise(function(_0xd50299,_0x28a4df){var _0x57ebf5=[];for(var _0x154b03 in _0xe9b1a0[_0xfff3('0x4b')]){if(_0xe9b1a0[_0xfff3('0x4b')]['hasOwnProperty'](_0x154b03)){var _0x4c2c05=_0xe9b1a0[_0xfff3('0x4b')][_0x154b03];var _0x48f135={'id':_0x4c2c05['id'],'available':_0x4c2c05[_0xfff3('0x4c')],'loggedIn':_0x4c2c05[_0xfff3('0x4d')],'name':_0x4c2c05[_0xfff3('0x4e')],'paused':_0x4c2c05[_0xfff3('0x4f')],'waiting':_0x4c2c05[_0xfff3('0x50')]};_0x57ebf5[_0xfff3('0x20')](_0x48f135);}}_0xd50299({'count':_0x57ebf5[_0xfff3('0x17')],'rows':_0x57ebf5});});},'MailQueues':function(_0x29f908){return new Promise(function(_0x13f85a,_0x4cd636){var _0x2a94b4=[];for(var _0x375e9f in _0xe9b1a0[_0xfff3('0x51')]){if(_0xe9b1a0[_0xfff3('0x51')][_0xfff3('0x46')](_0x375e9f)){var _0x47ba46=_0xe9b1a0[_0xfff3('0x51')][_0x375e9f];var _0xf56e56={'id':_0x47ba46['id'],'available':_0x47ba46['available'],'loggedIn':_0x47ba46[_0xfff3('0x4d')],'name':_0x47ba46['name'],'paused':_0x47ba46[_0xfff3('0x4f')],'waiting':_0x47ba46['waiting']};_0x2a94b4[_0xfff3('0x20')](_0xf56e56);}}_0x13f85a({'count':_0x2a94b4['length'],'rows':_0x2a94b4});});},'OpenchannelQueues':function(_0xbb2aa1){return new Promise(function(_0xdfc42a,_0x52123e){var _0x51747e=[];for(var _0x4ec8a7 in _0xe9b1a0[_0xfff3('0x52')]){if(_0xe9b1a0[_0xfff3('0x52')][_0xfff3('0x46')](_0x4ec8a7)){var _0x2c8dc9=_0xe9b1a0['openchannelQueues'][_0x4ec8a7];var _0x22ccf={'id':_0x2c8dc9['id'],'available':_0x2c8dc9['available'],'loggedIn':_0x2c8dc9[_0xfff3('0x4d')],'name':_0x2c8dc9[_0xfff3('0x4e')],'paused':_0x2c8dc9[_0xfff3('0x4f')],'waiting':_0x2c8dc9['waiting']};_0x51747e[_0xfff3('0x20')](_0x22ccf);}}_0xdfc42a({'count':_0x51747e['length'],'rows':_0x51747e});});},'SmsQueues':function(_0x4332e5){return new Promise(function(_0x1c8943,_0x29c44c){var _0x3e7c2a=[];for(var _0x4ddc7c in _0xe9b1a0[_0xfff3('0x53')]){if(_0xe9b1a0['smsQueues'][_0xfff3('0x46')](_0x4ddc7c)){var _0x15c477=_0xe9b1a0['smsQueues'][_0x4ddc7c];var _0x2d63ad={'id':_0x15c477['id'],'available':_0x15c477[_0xfff3('0x4c')],'loggedIn':_0x15c477[_0xfff3('0x4d')],'name':_0x15c477['name'],'paused':_0x15c477['paused'],'waiting':_0x15c477[_0xfff3('0x50')]};_0x3e7c2a['push'](_0x2d63ad);}}_0x1c8943({'count':_0x3e7c2a[_0xfff3('0x17')],'rows':_0x3e7c2a});});},'FaxQueues':function(_0x17ad65){return new Promise(function(_0x2e28e9,_0xc597c){var _0x34a748=[];for(var _0x58d315 in _0xe9b1a0['faxQueues']){if(_0xe9b1a0[_0xfff3('0x54')][_0xfff3('0x46')](_0x58d315)){var _0x230f08=_0xe9b1a0[_0xfff3('0x54')][_0x58d315];var _0x1bf6d5={'id':_0x230f08['id'],'available':_0x230f08[_0xfff3('0x4c')],'loggedIn':_0x230f08['loggedIn'],'name':_0x230f08[_0xfff3('0x4e')],'paused':_0x230f08[_0xfff3('0x4f')],'waiting':_0x230f08['waiting']};_0x34a748[_0xfff3('0x20')](_0x1bf6d5);}}_0x2e28e9({'count':_0x34a748[_0xfff3('0x17')],'rows':_0x34a748});});},'WhatsappQueues':function(_0x2095bd){return new Promise(function(_0x44c93a,_0x34c2f1){var _0x1706c0=[];for(var _0x50cad4 in _0xe9b1a0[_0xfff3('0x55')]){if(_0xe9b1a0['whatsappQueues'][_0xfff3('0x46')](_0x50cad4)){var _0xb6d74a=_0xe9b1a0[_0xfff3('0x55')][_0x50cad4];var _0xb9c270={'id':_0xb6d74a['id'],'available':_0xb6d74a[_0xfff3('0x4c')],'loggedIn':_0xb6d74a['loggedIn'],'name':_0xb6d74a[_0xfff3('0x4e')],'paused':_0xb6d74a['paused'],'waiting':_0xb6d74a['waiting']};_0x1706c0[_0xfff3('0x20')](_0xb9c270);}}_0x44c93a({'count':_0x1706c0[_0xfff3('0x17')],'rows':_0x1706c0});});},'ChatQueuesWaitingInteractions':function(_0x46641c){return new Promise(function(_0x56bba2,_0x14103f){var _0x1a22d8=_['values'](_0xe9b1a0[_0xfff3('0x56')]);_0x56bba2({'count':_0x1a22d8[_0xfff3('0x17')],'rows':_0x1a22d8});});},'MailQueuesWaitingInteractions':function(_0x49739a){return new Promise(function(_0x5522b9,_0x49634e){var _0x284579=_[_0xfff3('0x57')](_0xe9b1a0[_0xfff3('0x58')]);_0x5522b9({'count':_0x284579['length'],'rows':_0x284579});});},'OpenchannelQueuesWaitingInteractions':function(_0x59b285){return new Promise(function(_0x1d3d61,_0x1d7a54){var _0x37f0b1=_[_0xfff3('0x57')](_0xe9b1a0[_0xfff3('0x59')]);_0x1d3d61({'count':_0x37f0b1[_0xfff3('0x17')],'rows':_0x37f0b1});});},'SmsQueuesWaitingInteractions':function(_0x15cd8c){return new Promise(function(_0x29b4da,_0x274fac){var _0x552c22=_['values'](_0xe9b1a0[_0xfff3('0x5a')]);_0x29b4da({'count':_0x552c22['length'],'rows':_0x552c22});});},'FaxQueuesWaitingInteractions':function(_0x47ee61){return new Promise(function(_0x42ef12,_0x35822c){var _0x1afbab=_[_0xfff3('0x57')](_0xe9b1a0[_0xfff3('0x5b')]);_0x42ef12({'count':_0x1afbab[_0xfff3('0x17')],'rows':_0x1afbab});});},'WhatsappQueuesWaitingInteractions':function(_0x4a3b41){return new Promise(function(_0x4cd608,_0x1122ae){var _0x78effa=_[_0xfff3('0x57')](_0xe9b1a0[_0xfff3('0x5c')]);_0x4cd608({'count':_0x78effa['length'],'rows':_0x78effa});});}};var _0x3dc1e6=jayson[_0xfff3('0x5d')](_0x1b2456)['http']();_0x3dc1e6['on'](_0xfff3('0x30'),function(_0x2fac1a){logger[_0xfff3('0x30')](JSON['stringify'](_0x2fac1a));return _0x5f4cbe(_0x2fac1a);});_0x3dc1e6[_0xfff3('0x11')](0x232c,'127.0.0.1',function(){console['log'](_0xfff3('0x5e'),0x232c);return _0x3ac767(_0xfff3('0x5f')+0x232c);});});};
\ No newline at end of file