b6da433bc402ae0306f0dd3cbb81527260496916
[motion-next.git] / server / services / agi / channel.js
1 const a1025_0x5245=['STREAM\x20FILE\x20\x22%s\x22\x20\x22%s\x22','timeout','substring','SET\x20PRIORITY\x20%s','exec','wav','toString','setEncoding','line','AGI','BEEP','search','function','continueAt','match','headers','E_AGI_SOCKET_CLOSE','GET\x20DATA\x20\x22%s\x22\x20%s\x20%s','sendRequest','setExtension','SAY\x20DIGITS\x20%s\x20%s','substr','result=','indexOf','sync','join','NO\x20MESSAGE','length','noop','hangup','command','RECORD\x20FILE\x20\x22%s\x22\x20\x22%s\x22\x20\x22%s\x22\x20%s\x20%s\x20%s','destroy','no\x20code','getVariable','call','label','wait','E_AGI_SOCKET_TIMEOUT','streamFile','write','beep','code','startsWith','setTimeout','close','sayDigits','answer','replace','sayNumber','ready','utf8','WAIT','ID:%s\x20-\x20LABEL:\x20%s\x20-\x20MSG:\x20%s','isNumber','extension','error','util','sayPhonetic','getData','SET\x20EXTENSION\x20%s','prototype','format','EXEC\x20%s\x20%s','split','SET\x20CONTEXT\x20%s','inherits','E_AGI_SOCKET_ERROR','setPriority','emit','setContext'];(function(_0x3df589,_0x524515){const _0x1cf306=function(_0x32e4c0){while(--_0x32e4c0){_0x3df589['push'](_0x3df589['shift']());}};_0x1cf306(++_0x524515);}(a1025_0x5245,0xe0));const a1025_0x1cf3=function(_0x3df589,_0x524515){_0x3df589=_0x3df589-0x0;let _0x1cf306=a1025_0x5245[_0x3df589];return _0x1cf306;};const _0x7af4d3=a1025_0x1cf3;'use strict';const util=require(_0x7af4d3('0x2e')),_=require('lodash'),EventEmitter=require('events')['EventEmitter'],AGIReply=require('./reply'),AGIError=require('./error');function AGIChannel(_0x32e4c0){const _0x2b7fe6=_0x7af4d3,_0x157ad8=this,_0x4239b4=new AGIReply();let _0x4aead0=![],_0x5b76b3={};EventEmitter[_0x2b7fe6('0x18')](_0x157ad8),_0x32e4c0[_0x2b7fe6('0x43')](_0x2b7fe6('0x28')),_0x32e4c0[_0x2b7fe6('0x21')](0x8*0x3c*0x3c*0x3e8),_0x4239b4[_0x2b7fe6('0x43')](_0x2b7fe6('0x28')),_0x4239b4['on'](_0x2b7fe6('0x4'),function(_0x45c2d0){const _0x3a00c4=_0x2b7fe6;for(const _0x735bdf in _0x45c2d0){_0x157ad8[_0x735bdf]=_0x45c2d0[_0x735bdf];}_0x157ad8[_0x3a00c4('0x3a')](_0x3a00c4('0x27'));}),_0x4239b4['on'](_0x2b7fe6('0x44'),function(_0x1e94ec){const _0xef7f87=_0x2b7fe6;if(_0x1e94ec['toLowerCase']()==_0xef7f87('0x12')){_0x157ad8[_0xef7f87('0x3a')](_0xef7f87('0x12'));return;}_0x1e94ec[_0xef7f87('0x3e')](0x0,0xb)=='520-Invalid'&&(_0x4aead0=!![]);_0x4aead0?(_0x5b76b3['rx']+=_0x1e94ec+'\x0a',_0x1e94ec[_0xef7f87('0x0')]('520\x20End\x20of\x20proper')!=-0x1&&(_0x4aead0=![])):_0x5b76b3['rx']=_0x1e94ec;if(_0x4aead0)return;if(typeof _0x5b76b3['cb']==_0xef7f87('0x1')){let _0x1a1402=_0x5b76b3['rx'][_0xef7f87('0x3e')](0x0,0x3),_0x237460=null,_0xfceac9=null;_0x1a1402=parseInt(_0x1a1402);if(isNaN(_0x1a1402)){_0x5b76b3['cb'](null,{'code':0x1f4,'result':-0x1,'extra':_0xef7f87('0x16')});return;}if(_0x1a1402!=0xc8){_0x5b76b3['cb'](null,{'code':_0x1a1402,'result':-0x1,'extra':'KO'});return;}_0x237460=_0x5b76b3['rx'][_0xef7f87('0x3e')](0x4)[_0xef7f87('0x25')](_0xef7f87('0xb'),'');_0x237460[_0xef7f87('0xc')]('\x20')!=-0x1&&(_0x237460=_0x237460[_0xef7f87('0xa')](0x0,_0x237460[_0xef7f87('0xc')]('\x20')));_[_0xef7f87('0x20')](_0x237460,'-1')&&(_0x237460=parseInt(_0x237460));_0xfceac9=_0x5b76b3['rx'][_0xef7f87('0x35')]('\x20');if(_0xfceac9['length']==0x3)_0xfceac9=_0xfceac9[0x2][_0xef7f87('0x3e')](0x1,_0xfceac9[0x2][_0xef7f87('0x10')]-0x1);else{if(_0xfceac9['length']>0x3){const _0x36e039=/\((.+)\)/,_0x18edbc=_0x5b76b3['rx'][_0xef7f87('0x3')](_0x36e039);_0x18edbc?_0xfceac9=_0x18edbc[0x1]:_0xfceac9=null;}else _0xfceac9=null;}_0x5b76b3['cb'](null,{'code':_0x1a1402,'result':_0x237460,'extra':_0xfceac9});}}),_0x32e4c0['on'](_0x2b7fe6('0x2d'),function(_0x199adc){const _0x1859e6=_0x2b7fe6;_0x157ad8['emit'](_0x1859e6('0x2d'),new AGIError(_0x1859e6('0x38'),_0x199adc[_0x1859e6('0x1f')]));}),_0x32e4c0['on']('close',function(){const _0x4ab1c0=_0x2b7fe6;_0x157ad8[_0x4ab1c0('0x3a')](_0x4ab1c0('0x22'),new AGIError(_0x4ab1c0('0x5')));}),_0x32e4c0['on'](_0x2b7fe6('0x3d'),function(){const _0x5cf561=_0x2b7fe6;_0x157ad8[_0x5cf561('0x3a')](_0x5cf561('0x3d'),new AGIError(_0x5cf561('0x1b'))),_0x32e4c0[_0x5cf561('0x15')]();}),_0x32e4c0['pipe'](_0x4239b4),(this[_0x2b7fe6('0x13')]=function(_0xe9ebe9,_0x2af8af){const _0x3f38c4=_0x2b7fe6;_0xe9ebe9=_0xe9ebe9||'',_0x2af8af=typeof _0x2af8af==_0x3f38c4('0x1')?_0x2af8af:new Function(),_0x5b76b3={'tx':_0xe9ebe9,'rx':'','cb':_0x2af8af},_0x32e4c0[_0x3f38c4('0x1d')](_0xe9ebe9+'\x0a');},this['close']=function(){_0x32e4c0['destroy']();});}util[_0x7af4d3('0x37')](AGIChannel,EventEmitter),AGIChannel[_0x7af4d3('0x32')]['sendRequest']=function(_0x450a82){const _0x384e74=_0x7af4d3;return this['command'][_0x384e74('0xd')](this,_0x450a82);},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x24')]=function(){const _0x231bfe=_0x7af4d3;return this[_0x231bfe('0x7')]('ANSWER');},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x30')]=function(_0x1fe76d,_0x3dbd3f,_0x66381d){const _0x4f9afe=_0x7af4d3;return _0x1fe76d=_0x1fe76d===undefined?_0x4f9afe('0x1e'):_0x1fe76d,_0x3dbd3f=_0x3dbd3f===undefined?'5':_0x3dbd3f,_0x66381d=_0x66381d===undefined?'1':_0x66381d,this[_0x4f9afe('0x7')](util['format'](_0x4f9afe('0x6'),_0x1fe76d,_0x3dbd3f*0x3e8,_0x66381d));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x11')]=function(_0x133d05){const _0x2ef6b5=_0x7af4d3;return _0x133d05=_0x133d05||_0x2ef6b5('0xf'),this[_0x2ef6b5('0x7')](util[_0x2ef6b5('0x33')]('VERBOSE\x20\x22%s\x22',_0x133d05));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x40')]=function(_0x5eb03c,_0x4de373){const _0x5ab740=_0x7af4d3;if(_['isArray'](_0x4de373))return this[_0x5ab740('0x7')](util[_0x5ab740('0x33')](_0x5ab740('0x34'),_0x5eb03c,_0x4de373[_0x5ab740('0xe')](',')));return this['sendRequest'](util[_0x5ab740('0x33')](_0x5ab740('0x34'),_0x5eb03c,_0x4de373));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x3b')]=function(_0x742933){const _0x95aec2=_0x7af4d3;return this['sendRequest'](util[_0x95aec2('0x33')](_0x95aec2('0x36'),_0x742933));},AGIChannel['prototype'][_0x7af4d3('0x8')]=function(_0x47bef9){const _0x2ec18b=_0x7af4d3;return this['sendRequest'](util[_0x2ec18b('0x33')](_0x2ec18b('0x31'),_0x47bef9));},AGIChannel['prototype']['setPriority']=function(_0x2203a4){const _0x4be421=_0x7af4d3;return this[_0x4be421('0x7')](util[_0x4be421('0x33')](_0x4be421('0x3f'),_0x2203a4));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x12')]=function(){const _0x5e1d91=_0x7af4d3;return this[_0x5e1d91('0x7')]('HANGUP');},AGIChannel[_0x7af4d3('0x32')]['setVariable']=function(_0x137bb0,_0x3e8718){const _0x4a45d5=_0x7af4d3,_0x413b12=_['isBoolean'](_0x3e8718)||_[_0x4a45d5('0x2b')](_0x3e8718)?_0x3e8718[_0x4a45d5('0x42')]():_0x3e8718;return this[_0x4a45d5('0x7')](util[_0x4a45d5('0x33')]('SET\x20VARIABLE\x20%s\x20\x22%s\x22',_0x137bb0,_0x413b12?_0x413b12[_0x4a45d5('0x42')]()[_0x4a45d5('0x25')](/(\r\n|\n|\r)/gm,'\x20'):''));},AGIChannel['prototype'][_0x7af4d3('0x26')]=function(_0x2f6bba,_0x1c5e93){const _0x3e9cd0=_0x7af4d3;return this[_0x3e9cd0('0x7')](util[_0x3e9cd0('0x33')]('SAY\x20NUMBER\x20%s\x20%s',_0x2f6bba,_0x1c5e93));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x23')]=function(_0x2bec13,_0x3106c4){const _0x49b1bd=_0x7af4d3;return this[_0x49b1bd('0x7')](util[_0x49b1bd('0x33')](_0x49b1bd('0x9'),_0x2bec13,_0x3106c4));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x2f')]=function(_0x41a128,_0x1acc42){const _0x18bf7a=_0x7af4d3;return this[_0x18bf7a('0x7')](util['format']('SAY\x20PHONETIC\x20\x22%s\x22\x20%s',_0x41a128,_0x1acc42));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x2')]=function(_0x59502a,_0x375c86,_0x22d9c2){const _0x485d8f=_0x7af4d3;return _0x375c86=_0x375c86||this[_0x485d8f('0x2c')],_0x22d9c2=_0x22d9c2||0x1,this[_0x485d8f('0x3b')](_0x59502a),this[_0x485d8f('0x8')](_0x375c86),this[_0x485d8f('0x39')](_0x22d9c2),this[_0x485d8f('0x11')](util[_0x485d8f('0x33')]('GOTO\x20%s\x20%s\x20%s',_0x59502a,_0x375c86,_0x22d9c2));},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x17')]=function(_0x5eaf0c){const _0x94e94c=_0x7af4d3;return this[_0x94e94c('0x7')](util[_0x94e94c('0x33')]('GET\x20VARIABLE\x20\x22%s\x22',_0x5eaf0c));},AGIChannel['prototype']['recordFile']=function(_0x175bb0,_0x2310c6,_0x50cb54,_0x2d72a9,_0x189018,_0x122231){const _0xf3b96f=_0x7af4d3;return _0x2310c6=_0x2310c6||_0xf3b96f('0x41'),_0x50cb54=_0x50cb54||'',_0x2d72a9=_0x2d72a9===undefined?-0x1:_0x2d72a9==='-1'?-0x1:_0x2d72a9*0x3e8,_0x189018=_0x189018===undefined?'':'s='+_0x189018,_0x122231=_0x122231?_0xf3b96f('0x46'):'',this['sendRequest'](util[_0xf3b96f('0x33')](_0xf3b96f('0x14'),_0x175bb0,_0x2310c6,_0x50cb54,_0x2d72a9,_0x122231,_0x189018));},AGIChannel['prototype'][_0x7af4d3('0x1c')]=function(_0x10a4ae,_0x5568cf){const _0x33b95f=_0x7af4d3;return _0x5568cf=_0x5568cf||'',this[_0x33b95f('0x7')](util['format'](_0x33b95f('0x3c'),_0x10a4ae,_0x5568cf));},AGIChannel['prototype']['agi']=function(_0x4d4a89){const _0x2b933a=_0x7af4d3;return this[_0x2b933a('0x40')](_0x2b933a('0x45'),_0x4d4a89);},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x1a')]=function(_0x1511aa){const _0x43bc0f=_0x7af4d3;return this[_0x43bc0f('0x40')](_0x43bc0f('0x29'),_0x1511aa);},AGIChannel[_0x7af4d3('0x32')][_0x7af4d3('0x2d')]=function(_0x3ccb39,_0x564651){const _0x54d0a4=_0x7af4d3;return this[_0x54d0a4('0x11')](util[_0x54d0a4('0x33')](_0x54d0a4('0x2a'),_0x3ccb39['id'],_0x3ccb39[_0x54d0a4('0x19')],_0x564651)),{'code':0x1f4,'result':'-1','extra':''};},module['exports']=AGIChannel;