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