changes to 000
parent
f923001a6f
commit
a47355c13c
|
@ -9,14 +9,9 @@ export default class PBX {
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
||||||
this.install();
|
|
||||||
this.pageDTMF();
|
this.pageDTMF();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected install() {
|
|
||||||
this.client.util.ari.start('page-dtmf');
|
|
||||||
}
|
|
||||||
|
|
||||||
public pageDTMF() {
|
public pageDTMF() {
|
||||||
this.client.util.ari.on('StasisStart', async (event, channel) => {
|
this.client.util.ari.on('StasisStart', async (event, channel) => {
|
||||||
if (event.application !== 'page-dtmf') return;
|
if (event.application !== 'page-dtmf') return;
|
||||||
|
@ -30,12 +25,13 @@ export default class PBX {
|
||||||
const pagerNumber: string[] = [];
|
const pagerNumber: string[] = [];
|
||||||
const pagerCode: string[] = [];
|
const pagerCode: string[] = [];
|
||||||
channel.answer();
|
channel.answer();
|
||||||
await channel.play({
|
const pnPlayback = await channel.play({
|
||||||
media: 'sound:please-enter-the-pn',
|
media: 'sound:please-enter-the-pn',
|
||||||
}, undefined);
|
}, undefined);
|
||||||
channel.on('ChannelDtmfReceived', async (ev) => {
|
channel.on('ChannelDtmfReceived', async (ev) => {
|
||||||
if (status === 0) {
|
if (status === 0) {
|
||||||
if (ev.digit === '#') {
|
if (ev.digit === '#') {
|
||||||
|
pnPlayback.stop();
|
||||||
await channel.play({
|
await channel.play({
|
||||||
media: 'sound:please-enter-the-pc',
|
media: 'sound:please-enter-the-pc',
|
||||||
}, undefined);
|
}, undefined);
|
||||||
|
@ -44,14 +40,16 @@ export default class PBX {
|
||||||
}
|
}
|
||||||
pagerNumber.push(ev.digit);
|
pagerNumber.push(ev.digit);
|
||||||
} else if (status === 1) {
|
} else if (status === 1) {
|
||||||
|
const processingPlayback = this.client.util.ari.Playback();
|
||||||
if (ev.digit === '#') {
|
if (ev.digit === '#') {
|
||||||
await channel.play({
|
await channel.play({
|
||||||
media: 'sound:pls-hold-process-tx',
|
media: 'sound:pls-hold-process-tx',
|
||||||
}, undefined);
|
}, processingPlayback);
|
||||||
|
|
||||||
const Page = <PageCommand> this.client.commands.get('page');
|
const Page = <PageCommand> this.client.commands.get('page');
|
||||||
const page = await Page.page(pagerNumber.join(''), pager.num, pagerCode.join(''), message);
|
const page = await Page.page(pagerNumber.join(''), pager.num, pagerCode.join(''), message);
|
||||||
if (page.status === true) {
|
if (page.status === true) {
|
||||||
|
processingPlayback.stop();
|
||||||
const playback = await channel.play({
|
const playback = await channel.play({
|
||||||
media: 'sound:page-delivered',
|
media: 'sound:page-delivered',
|
||||||
}, undefined);
|
}, undefined);
|
||||||
|
@ -65,6 +63,7 @@ export default class PBX {
|
||||||
} catch {
|
} catch {
|
||||||
this.client.util.handleError(new Error(page.message));
|
this.client.util.handleError(new Error(page.message));
|
||||||
}
|
}
|
||||||
|
processingPlayback.stop();
|
||||||
const playback = await channel.play({
|
const playback = await channel.play({
|
||||||
media: 'sound:request-error',
|
media: 'sound:request-error',
|
||||||
}, undefined);
|
}, undefined);
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default class Util {
|
||||||
|
|
||||||
private async load() {
|
private async load() {
|
||||||
this.ari = await ARIClient.connect('http://10.8.0.1:8088/ari', 'cr0', this.client.config.ariClientKey);
|
this.ari = await ARIClient.connect('http://10.8.0.1:8088/ari', 'cr0', this.client.config.ariClientKey);
|
||||||
this.ari.start('cr-zero');
|
this.ari.start(['cr-zero', 'page-dtmf']);
|
||||||
|
|
||||||
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../google.json`;
|
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../google.json`;
|
||||||
this.tts = new GoogleTTS.TextToSpeechClient();
|
this.tts = new GoogleTTS.TextToSpeechClient();
|
||||||
|
|
Loading…
Reference in New Issue