Built motion from commit b517aaa2a6638133380e4d135c64a80893061362. Version 3.0.0...
[motion-next.git] / server / services / agi / channel.js
1 const a1025_0x13c3=['match','noop','write','GOTO\x20%s\x20%s\x20%s','ANSWER','answer','indexOf','EXEC\x20%s\x20%s','line','SAY\x20DIGITS\x20%s\x20%s','recordFile','sync','SAY\x20PHONETIC\x20\x22%s\x22\x20%s','exec','substring','GET\x20VARIABLE\x20\x22%s\x22','agi','format','E_AGI_SOCKET_TIMEOUT','sayDigits','timeout','error','length','AGI','520\x20End\x20of\x20proper','setPriority','search','ID:%s\x20-\x20LABEL:\x20%s\x20-\x20MSG:\x20%s','prototype','setEncoding','extension','function','EventEmitter','wait','hangup','E_AGI_SOCKET_CLOSE','command','headers','utf8','E_AGI_SOCKET_ERROR','SET\x20CONTEXT\x20%s','exports','getVariable','substr','join','destroy','WAIT','startsWith','ready','setContext','./reply','STREAM\x20FILE\x20\x22%s\x22\x20\x22%s\x22','pipe','no\x20code','SET\x20VARIABLE\x20%s\x20\x22%s\x22','./error','sendRequest','VERBOSE\x20\x22%s\x22','RECORD\x20FILE\x20\x22%s\x22\x20\x22%s\x22\x20\x22%s\x22\x20%s\x20%s\x20%s','lodash','label','replace','emit','streamFile','isNumber','close','520-Invalid','toLowerCase','util','sayPhonetic','SET\x20PRIORITY\x20%s','sayNumber','GET\x20DATA\x20\x22%s\x22\x20%s\x20%s'];(function(_0x36a659,_0x13c36f){const _0x47fc43=function(_0x5977d8){while(--_0x5977d8){_0x36a659['push'](_0x36a659['shift']());}};_0x47fc43(++_0x13c36f);}(a1025_0x13c3,0xf6));const a1025_0x47fc=function(_0x36a659,_0x13c36f){_0x36a659=_0x36a659-0x0;let _0x47fc43=a1025_0x13c3[_0x36a659];return _0x47fc43;};const _0x2f3797=a1025_0x47fc;'use strict';const util=require(_0x2f3797('0x29')),_=require(_0x2f3797('0x20')),EventEmitter=require('events')[_0x2f3797('0x5')],AGIReply=require(_0x2f3797('0x17')),AGIError=require(_0x2f3797('0x1c'));function AGIChannel(_0x5977d8){const _0x1ccd6f=_0x2f3797,_0x39f411=this,_0x552240=new AGIReply();let _0x4c6af9=![],_0x10431f={};EventEmitter['call'](_0x39f411),_0x5977d8[_0x1ccd6f('0x2')](_0x1ccd6f('0xb')),_0x5977d8['setTimeout'](0x8*0x3c*0x3c*0x3e8),_0x552240[_0x1ccd6f('0x2')](_0x1ccd6f('0xb')),_0x552240['on'](_0x1ccd6f('0xa'),function(_0xc9c848){const _0x4e7005=_0x1ccd6f;for(const _0x550c18 in _0xc9c848){_0x39f411[_0x550c18]=_0xc9c848[_0x550c18];}_0x39f411['emit'](_0x4e7005('0x15'));}),_0x552240['on'](_0x1ccd6f('0x36'),function(_0x1afbbb){const _0x19d740=_0x1ccd6f;if(_0x1afbbb[_0x19d740('0x28')]()==_0x19d740('0x7')){_0x39f411[_0x19d740('0x23')](_0x19d740('0x7'));return;}_0x1afbbb[_0x19d740('0x3c')](0x0,0xb)==_0x19d740('0x27')&&(_0x4c6af9=!![]);_0x4c6af9?(_0x10431f['rx']+=_0x1afbbb+'\x0a',_0x1afbbb[_0x19d740('0x48')](_0x19d740('0x46'))!=-0x1&&(_0x4c6af9=![])):_0x10431f['rx']=_0x1afbbb;if(_0x4c6af9)return;if(typeof _0x10431f['cb']==_0x19d740('0x4')){let _0x3bc155=_0x10431f['rx']['substring'](0x0,0x3),_0x40d5d5=null,_0x5bf9af=null;_0x3bc155=parseInt(_0x3bc155);if(isNaN(_0x3bc155)){_0x10431f['cb'](null,{'code':0x1f4,'result':-0x1,'extra':_0x19d740('0x1a')});return;}if(_0x3bc155!=0xc8){_0x10431f['cb'](null,{'code':_0x3bc155,'result':-0x1,'extra':'KO'});return;}_0x40d5d5=_0x10431f['rx'][_0x19d740('0x3c')](0x4)['replace']('result=','');_0x40d5d5[_0x19d740('0x34')]('\x20')!=-0x1&&(_0x40d5d5=_0x40d5d5[_0x19d740('0x10')](0x0,_0x40d5d5[_0x19d740('0x34')]('\x20')));_[_0x19d740('0x14')](_0x40d5d5,'-1')&&(_0x40d5d5=parseInt(_0x40d5d5));_0x5bf9af=_0x10431f['rx']['split']('\x20');if(_0x5bf9af['length']==0x3)_0x5bf9af=_0x5bf9af[0x2]['substring'](0x1,_0x5bf9af[0x2][_0x19d740('0x44')]-0x1);else{if(_0x5bf9af[_0x19d740('0x44')]>0x3){const _0x404844=/\((.+)\)/,_0x55256b=_0x10431f['rx'][_0x19d740('0x2e')](_0x404844);_0x55256b?_0x5bf9af=_0x55256b[0x1]:_0x5bf9af=null;}else _0x5bf9af=null;}_0x10431f['cb'](null,{'code':_0x3bc155,'result':_0x40d5d5,'extra':_0x5bf9af});}}),_0x5977d8['on'](_0x1ccd6f('0x43'),function(_0x4a3528){const _0x1223df=_0x1ccd6f;_0x39f411[_0x1223df('0x23')]('error',new AGIError(_0x1223df('0xc'),_0x4a3528['code']));}),_0x5977d8['on']('close',function(){const _0x9bc833=_0x1ccd6f;_0x39f411[_0x9bc833('0x23')](_0x9bc833('0x26'),new AGIError(_0x9bc833('0x8')));}),_0x5977d8['on'](_0x1ccd6f('0x42'),function(){const _0x59d73d=_0x1ccd6f;_0x39f411[_0x59d73d('0x23')](_0x59d73d('0x42'),new AGIError(_0x59d73d('0x40'))),_0x5977d8[_0x59d73d('0x12')]();}),_0x5977d8[_0x1ccd6f('0x19')](_0x552240),(this[_0x1ccd6f('0x9')]=function(_0x5b72d7,_0x2f88ce){const _0x521272=_0x1ccd6f;_0x5b72d7=_0x5b72d7||'',_0x2f88ce=typeof _0x2f88ce==_0x521272('0x4')?_0x2f88ce:new Function(),_0x10431f={'tx':_0x5b72d7,'rx':'','cb':_0x2f88ce},_0x5977d8[_0x521272('0x30')](_0x5b72d7+'\x0a');},this[_0x1ccd6f('0x26')]=function(){const _0x3c4c56=_0x1ccd6f;_0x5977d8[_0x3c4c56('0x12')]();});}util['inherits'](AGIChannel,EventEmitter),AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x1d')]=function(_0x2cd1a3){const _0x2db6e4=_0x2f3797;return this['command'][_0x2db6e4('0x39')](this,_0x2cd1a3);},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x33')]=function(){const _0x5143c9=_0x2f3797;return this[_0x5143c9('0x1d')](_0x5143c9('0x32'));},AGIChannel[_0x2f3797('0x1')]['getData']=function(_0x1066e4,_0x5dfd37,_0x2079ed){const _0x1b24b8=_0x2f3797;return _0x1066e4=_0x1066e4===undefined?'beep':_0x1066e4,_0x5dfd37=_0x5dfd37===undefined?'5':_0x5dfd37,_0x2079ed=_0x2079ed===undefined?'1':_0x2079ed,this[_0x1b24b8('0x1d')](util['format'](_0x1b24b8('0x2d'),_0x1066e4,_0x5dfd37*0x3e8,_0x2079ed));},AGIChannel['prototype'][_0x2f3797('0x2f')]=function(_0x2d13d1){const _0xc11d57=_0x2f3797;return _0x2d13d1=_0x2d13d1||'NO\x20MESSAGE',this[_0xc11d57('0x1d')](util[_0xc11d57('0x3f')](_0xc11d57('0x1e'),_0x2d13d1));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x3b')]=function(_0x4d3ce9,_0x17c9f9){const _0x184a3f=_0x2f3797;if(_['isArray'](_0x17c9f9))return this[_0x184a3f('0x1d')](util[_0x184a3f('0x3f')](_0x184a3f('0x35'),_0x4d3ce9,_0x17c9f9[_0x184a3f('0x11')](',')));return this['sendRequest'](util[_0x184a3f('0x3f')](_0x184a3f('0x35'),_0x4d3ce9,_0x17c9f9));},AGIChannel[_0x2f3797('0x1')]['setContext']=function(_0x57e5da){const _0x4898ab=_0x2f3797;return this[_0x4898ab('0x1d')](util[_0x4898ab('0x3f')](_0x4898ab('0xd'),_0x57e5da));},AGIChannel[_0x2f3797('0x1')]['setExtension']=function(_0x52d723){const _0x13b073=_0x2f3797;return this[_0x13b073('0x1d')](util[_0x13b073('0x3f')]('SET\x20EXTENSION\x20%s',_0x52d723));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x47')]=function(_0x478487){const _0x55cc41=_0x2f3797;return this[_0x55cc41('0x1d')](util[_0x55cc41('0x3f')](_0x55cc41('0x2b'),_0x478487));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x7')]=function(){return this['sendRequest']('HANGUP');},AGIChannel[_0x2f3797('0x1')]['setVariable']=function(_0xe6c260,_0xe6c5db){const _0x4d1395=_0x2f3797,_0xf49aab=_['isBoolean'](_0xe6c5db)||_[_0x4d1395('0x25')](_0xe6c5db)?_0xe6c5db['toString']():_0xe6c5db;return this[_0x4d1395('0x1d')](util[_0x4d1395('0x3f')](_0x4d1395('0x1b'),_0xe6c260,_0xf49aab?_0xf49aab['toString']()[_0x4d1395('0x22')](/(\r\n|\n|\r)/gm,'\x20'):''));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x2c')]=function(_0x53dc78,_0x1306fe){const _0x398f0c=_0x2f3797;return this[_0x398f0c('0x1d')](util[_0x398f0c('0x3f')]('SAY\x20NUMBER\x20%s\x20%s',_0x53dc78,_0x1306fe));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x41')]=function(_0x3cb57a,_0x2f2eb0){const _0x4ccfb1=_0x2f3797;return this['sendRequest'](util['format'](_0x4ccfb1('0x37'),_0x3cb57a,_0x2f2eb0));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x2a')]=function(_0x1a9ee6,_0x3fce2f){const _0xef2213=_0x2f3797;return this[_0xef2213('0x1d')](util['format'](_0xef2213('0x3a'),_0x1a9ee6,_0x3fce2f));},AGIChannel[_0x2f3797('0x1')]['continueAt']=function(_0x1ca2e4,_0x1021fe,_0x44f173){const _0x31cb3b=_0x2f3797;return _0x1021fe=_0x1021fe||this[_0x31cb3b('0x3')],_0x44f173=_0x44f173||0x1,this[_0x31cb3b('0x16')](_0x1ca2e4),this['setExtension'](_0x1021fe),this['setPriority'](_0x44f173),this[_0x31cb3b('0x2f')](util[_0x31cb3b('0x3f')](_0x31cb3b('0x31'),_0x1ca2e4,_0x1021fe,_0x44f173));},AGIChannel['prototype'][_0x2f3797('0xf')]=function(_0x26f72a){const _0x21dc6d=_0x2f3797;return this[_0x21dc6d('0x1d')](util[_0x21dc6d('0x3f')](_0x21dc6d('0x3d'),_0x26f72a));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x38')]=function(_0x67e05e,_0x551304,_0x389925,_0x1590c0,_0x3311c8,_0x3bcff2){const _0x8972e1=_0x2f3797;return _0x551304=_0x551304||'wav',_0x389925=_0x389925||'',_0x1590c0=_0x1590c0===undefined?-0x1:_0x1590c0==='-1'?-0x1:_0x1590c0*0x3e8,_0x3311c8=_0x3311c8===undefined?'':'s='+_0x3311c8,_0x3bcff2=_0x3bcff2?'BEEP':'',this[_0x8972e1('0x1d')](util[_0x8972e1('0x3f')](_0x8972e1('0x1f'),_0x67e05e,_0x551304,_0x389925,_0x1590c0,_0x3bcff2,_0x3311c8));},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x24')]=function(_0x409e5d,_0x2a0cf0){const _0x30741e=_0x2f3797;return _0x2a0cf0=_0x2a0cf0||'',this[_0x30741e('0x1d')](util[_0x30741e('0x3f')](_0x30741e('0x18'),_0x409e5d,_0x2a0cf0));},AGIChannel['prototype'][_0x2f3797('0x3e')]=function(_0x3a0018){const _0x12f27a=_0x2f3797;return this['exec'](_0x12f27a('0x45'),_0x3a0018);},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x6')]=function(_0x589517){const _0x11b667=_0x2f3797;return this[_0x11b667('0x3b')](_0x11b667('0x13'),_0x589517);},AGIChannel[_0x2f3797('0x1')][_0x2f3797('0x43')]=function(_0x1ed1b6,_0x5d92f0){const _0xed7c39=_0x2f3797;return this['noop'](util[_0xed7c39('0x3f')](_0xed7c39('0x0'),_0x1ed1b6['id'],_0x1ed1b6[_0xed7c39('0x21')],_0x5d92f0)),{'code':0x1f4,'result':'-1','extra':''};},module[_0x2f3797('0xe')]=AGIChannel;