e674db5a372faef5fe216699465f54b03c5d4e99
[motion-next.git] / server / services / agi / channel.js
1 const a1026_0x5c41=['toLowerCase','agi','noop','setEncoding','getData','sync','startsWith','sayPhonetic','setExtension','function','SAY\x20NUMBER\x20%s\x20%s','exec','answer','streamFile','EventEmitter','STREAM\x20FILE\x20\x22%s\x22\x20\x22%s\x22','isArray','error','WAIT','exports','emit','substr','SET\x20EXTENSION\x20%s','label','length','utf8','getVariable','520-Invalid','util','replace','recordFile','no\x20code','isBoolean','GET\x20VARIABLE\x20\x22%s\x22','timeout','ID:%s\x20-\x20LABEL:\x20%s\x20-\x20MSG:\x20%s','./reply','E_AGI_SOCKET_ERROR','setPriority','indexOf','write','SET\x20CONTEXT\x20%s','destroy','join','setContext','extension','substring','ANSWER','toString','NO\x20MESSAGE','close','command','beep','line','HANGUP','ready','lodash','prototype','wait','hangup','call','E_AGI_SOCKET_CLOSE','./error','VERBOSE\x20\x22%s\x22','SET\x20VARIABLE\x20%s\x20\x22%s\x22','sayDigits','SAY\x20DIGITS\x20%s\x20%s','format','code','pipe','EXEC\x20%s\x20%s','isNumber','wav','sendRequest'];(function(_0x1e110d,_0x5c41b3){const _0x4df060=function(_0x26f0e8){while(--_0x26f0e8){_0x1e110d['push'](_0x1e110d['shift']());}};_0x4df060(++_0x5c41b3);}(a1026_0x5c41,0xd0));const a1026_0x4df0=function(_0x1e110d,_0x5c41b3){_0x1e110d=_0x1e110d-0x0;let _0x4df060=a1026_0x5c41[_0x1e110d];return _0x4df060;};const _0x4feba0=a1026_0x4df0;'use strict';const util=require(_0x4feba0('0x2a')),_=require(_0x4feba0('0x46')),EventEmitter=require('events')[_0x4feba0('0x1c')],AGIReply=require(_0x4feba0('0x32')),AGIError=require(_0x4feba0('0x2'));function AGIChannel(_0x26f0e8){const _0x159edd=_0x4feba0,_0xfae39a=this,_0x41c3d6=new AGIReply();let _0x6d0af4=![],_0x1dd711={};EventEmitter[_0x159edd('0x0')](_0xfae39a),_0x26f0e8[_0x159edd('0x11')](_0x159edd('0x27')),_0x26f0e8['setTimeout'](0x8*0x3c*0x3c*0x3e8),_0x41c3d6['setEncoding']('utf8'),_0x41c3d6['on']('headers',function(_0x11d8bf){const _0x2d9134=_0x159edd;for(const _0x1bfe39 in _0x11d8bf){_0xfae39a[_0x1bfe39]=_0x11d8bf[_0x1bfe39];}_0xfae39a[_0x2d9134('0x22')](_0x2d9134('0x45'));}),_0x41c3d6['on'](_0x159edd('0x43'),function(_0x20f90e){const _0x43ac39=_0x159edd;if(_0x20f90e[_0x43ac39('0xe')]()==_0x43ac39('0x49')){_0xfae39a[_0x43ac39('0x22')](_0x43ac39('0x49'));return;}_0x20f90e['substring'](0x0,0xb)==_0x43ac39('0x29')&&(_0x6d0af4=!![]);_0x6d0af4?(_0x1dd711['rx']+=_0x20f90e+'\x0a',_0x20f90e['search']('520\x20End\x20of\x20proper')!=-0x1&&(_0x6d0af4=![])):_0x1dd711['rx']=_0x20f90e;if(_0x6d0af4)return;if(typeof _0x1dd711['cb']==_0x43ac39('0x17')){let _0x11ec63=_0x1dd711['rx'][_0x43ac39('0x3c')](0x0,0x3),_0x2c0eab=null,_0x1a94f1=null;_0x11ec63=parseInt(_0x11ec63);if(isNaN(_0x11ec63)){_0x1dd711['cb'](null,{'code':0x1f4,'result':-0x1,'extra':_0x43ac39('0x2d')});return;}if(_0x11ec63!=0xc8){_0x1dd711['cb'](null,{'code':_0x11ec63,'result':-0x1,'extra':'KO'});return;}_0x2c0eab=_0x1dd711['rx'][_0x43ac39('0x3c')](0x4)[_0x43ac39('0x2b')]('result=','');_0x2c0eab[_0x43ac39('0x35')]('\x20')!=-0x1&&(_0x2c0eab=_0x2c0eab[_0x43ac39('0x23')](0x0,_0x2c0eab[_0x43ac39('0x35')]('\x20')));_[_0x43ac39('0x14')](_0x2c0eab,'-1')&&(_0x2c0eab=parseInt(_0x2c0eab));_0x1a94f1=_0x1dd711['rx']['split']('\x20');if(_0x1a94f1[_0x43ac39('0x26')]==0x3)_0x1a94f1=_0x1a94f1[0x2][_0x43ac39('0x3c')](0x1,_0x1a94f1[0x2][_0x43ac39('0x26')]-0x1);else{if(_0x1a94f1[_0x43ac39('0x26')]>0x3){const _0x2190e9=/\((.+)\)/,_0x2d08b1=_0x1dd711['rx']['match'](_0x2190e9);_0x2d08b1?_0x1a94f1=_0x2d08b1[0x1]:_0x1a94f1=null;}else _0x1a94f1=null;}_0x1dd711['cb'](null,{'code':_0x11ec63,'result':_0x2c0eab,'extra':_0x1a94f1});}}),_0x26f0e8['on'](_0x159edd('0x1f'),function(_0x32251f){const _0x72c576=_0x159edd;_0xfae39a[_0x72c576('0x22')](_0x72c576('0x1f'),new AGIError(_0x72c576('0x33'),_0x32251f[_0x72c576('0x8')]));}),_0x26f0e8['on'](_0x159edd('0x40'),function(){const _0x4d6cf1=_0x159edd;_0xfae39a['emit'](_0x4d6cf1('0x40'),new AGIError(_0x4d6cf1('0x1')));}),_0x26f0e8['on']('timeout',function(){const _0x41d96a=_0x159edd;_0xfae39a[_0x41d96a('0x22')](_0x41d96a('0x30'),new AGIError('E_AGI_SOCKET_TIMEOUT')),_0x26f0e8[_0x41d96a('0x38')]();}),_0x26f0e8[_0x159edd('0x9')](_0x41c3d6),(this[_0x159edd('0x41')]=function(_0x5060e0,_0x5095a8){const _0x164583=_0x159edd;_0x5060e0=_0x5060e0||'',_0x5095a8=typeof _0x5095a8=='function'?_0x5095a8:new Function(),_0x1dd711={'tx':_0x5060e0,'rx':'','cb':_0x5095a8},_0x26f0e8[_0x164583('0x36')](_0x5060e0+'\x0a');},this[_0x159edd('0x40')]=function(){_0x26f0e8['destroy']();});}util['inherits'](AGIChannel,EventEmitter),AGIChannel[_0x4feba0('0x47')][_0x4feba0('0xd')]=function(_0x11ac63){const _0x409952=_0x4feba0;return this['command'][_0x409952('0x13')](this,_0x11ac63);},AGIChannel['prototype'][_0x4feba0('0x1a')]=function(){const _0x4a7a2c=_0x4feba0;return this['sendRequest'](_0x4a7a2c('0x3d'));},AGIChannel['prototype'][_0x4feba0('0x12')]=function(_0x1980af,_0x1a48bc,_0x216e42){const _0x9bc1c1=_0x4feba0;return _0x1980af=_0x1980af===undefined?_0x9bc1c1('0x42'):_0x1980af,_0x1a48bc=_0x1a48bc===undefined?'5':_0x1a48bc,_0x216e42=_0x216e42===undefined?'1':_0x216e42,this['sendRequest'](util[_0x9bc1c1('0x7')]('GET\x20DATA\x20\x22%s\x22\x20%s\x20%s',_0x1980af,_0x1a48bc*0x3e8,_0x216e42));},AGIChannel['prototype']['noop']=function(_0x3d2e15){const _0x1c2aed=_0x4feba0;return _0x3d2e15=_0x3d2e15||_0x1c2aed('0x3f'),this[_0x1c2aed('0xd')](util[_0x1c2aed('0x7')](_0x1c2aed('0x3'),_0x3d2e15));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x19')]=function(_0x46509f,_0xcee54a){const _0x1e0c97=_0x4feba0;if(_[_0x1e0c97('0x1e')](_0xcee54a))return this[_0x1e0c97('0xd')](util[_0x1e0c97('0x7')]('EXEC\x20%s\x20%s',_0x46509f,_0xcee54a[_0x1e0c97('0x39')](',')));return this[_0x1e0c97('0xd')](util['format'](_0x1e0c97('0xa'),_0x46509f,_0xcee54a));},AGIChannel[_0x4feba0('0x47')]['setContext']=function(_0x494b7d){const _0x4f798c=_0x4feba0;return this[_0x4f798c('0xd')](util[_0x4f798c('0x7')](_0x4f798c('0x37'),_0x494b7d));},AGIChannel['prototype'][_0x4feba0('0x16')]=function(_0x558960){const _0x5540ad=_0x4feba0;return this[_0x5540ad('0xd')](util['format'](_0x5540ad('0x24'),_0x558960));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x34')]=function(_0x410f10){const _0x1aae36=_0x4feba0;return this[_0x1aae36('0xd')](util[_0x1aae36('0x7')]('SET\x20PRIORITY\x20%s',_0x410f10));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x49')]=function(){const _0x2d7b6e=_0x4feba0;return this['sendRequest'](_0x2d7b6e('0x44'));},AGIChannel[_0x4feba0('0x47')]['setVariable']=function(_0x14cab1,_0x1187f5){const _0x31a684=_0x4feba0,_0x2bc4d6=_[_0x31a684('0x2e')](_0x1187f5)||_[_0x31a684('0xb')](_0x1187f5)?_0x1187f5[_0x31a684('0x3e')]():_0x1187f5;return this[_0x31a684('0xd')](util['format'](_0x31a684('0x4'),_0x14cab1,_0x2bc4d6?_0x2bc4d6['toString']()['replace'](/(\r\n|\n|\r)/gm,'\x20'):''));},AGIChannel['prototype']['sayNumber']=function(_0x5f471d,_0x3fa436){const _0x2c61ca=_0x4feba0;return this[_0x2c61ca('0xd')](util[_0x2c61ca('0x7')](_0x2c61ca('0x18'),_0x5f471d,_0x3fa436));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x5')]=function(_0x18add0,_0x173023){const _0x228b91=_0x4feba0;return this['sendRequest'](util['format'](_0x228b91('0x6'),_0x18add0,_0x173023));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x15')]=function(_0x46f2c3,_0x17f465){const _0x537cdf=_0x4feba0;return this[_0x537cdf('0xd')](util[_0x537cdf('0x7')]('SAY\x20PHONETIC\x20\x22%s\x22\x20%s',_0x46f2c3,_0x17f465));},AGIChannel[_0x4feba0('0x47')]['continueAt']=function(_0x390487,_0x67afc7,_0x16bade){const _0x128cdd=_0x4feba0;return _0x67afc7=_0x67afc7||this[_0x128cdd('0x3b')],_0x16bade=_0x16bade||0x1,this[_0x128cdd('0x3a')](_0x390487),this['setExtension'](_0x67afc7),this[_0x128cdd('0x34')](_0x16bade),this[_0x128cdd('0x10')](util[_0x128cdd('0x7')]('GOTO\x20%s\x20%s\x20%s',_0x390487,_0x67afc7,_0x16bade));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x28')]=function(_0xae2ca1){const _0x509df4=_0x4feba0;return this['sendRequest'](util[_0x509df4('0x7')](_0x509df4('0x2f'),_0xae2ca1));},AGIChannel['prototype'][_0x4feba0('0x2c')]=function(_0x1b18aa,_0x1c5946,_0x1d104c,_0x4e246e,_0x3f6945,_0x1a9c8c){const _0x50d961=_0x4feba0;return _0x1c5946=_0x1c5946||_0x50d961('0xc'),_0x1d104c=_0x1d104c||'',_0x4e246e=_0x4e246e===undefined?-0x1:_0x4e246e==='-1'?-0x1:_0x4e246e*0x3e8,_0x3f6945=_0x3f6945===undefined?'':'s='+_0x3f6945,_0x1a9c8c=_0x1a9c8c?'BEEP':'',this[_0x50d961('0xd')](util[_0x50d961('0x7')]('RECORD\x20FILE\x20\x22%s\x22\x20\x22%s\x22\x20\x22%s\x22\x20%s\x20%s\x20%s',_0x1b18aa,_0x1c5946,_0x1d104c,_0x4e246e,_0x1a9c8c,_0x3f6945));},AGIChannel['prototype'][_0x4feba0('0x1b')]=function(_0x25b5d6,_0x59436f){const _0x52ba34=_0x4feba0;return _0x59436f=_0x59436f||'',this[_0x52ba34('0xd')](util[_0x52ba34('0x7')](_0x52ba34('0x1d'),_0x25b5d6,_0x59436f));},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0xf')]=function(_0x5e6dbc){const _0x429870=_0x4feba0;return this[_0x429870('0x19')]('AGI',_0x5e6dbc);},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x48')]=function(_0x5ada62){const _0x5a4f58=_0x4feba0;return this[_0x5a4f58('0x19')](_0x5a4f58('0x20'),_0x5ada62);},AGIChannel[_0x4feba0('0x47')][_0x4feba0('0x1f')]=function(_0xe32018,_0x19f604){const _0x237d47=_0x4feba0;return this['noop'](util[_0x237d47('0x7')](_0x237d47('0x31'),_0xe32018['id'],_0xe32018[_0x237d47('0x25')],_0x19f604)),{'code':0x1f4,'result':'-1','extra':''};},module[_0x4feba0('0x21')]=AGIChannel;