From 98df57731191013688a7f26f736f3d0ecf7cc750 Mon Sep 17 00:00:00 2001 From: sD Date: Tue, 14 Jul 2020 19:16:28 +0200 Subject: add function to check the words --- webAO/client.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d4b6bc9..e3f4d95 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1647,6 +1647,8 @@ async changeBackground(position) { appendICLog(this.chatmsg.content, displayname); + checkCallword(this.chatmsg.content); + // start checking the files try { const { url: speakUrl } = await this.oneSuccess([ @@ -2431,6 +2433,26 @@ function appendICLog(msg, name = "", time = new Date()) { lastICMessageTime = new Date(); } +/** + * check if the message contains an entry on our callword list + * @param {String} message + */ +export function checkCallword(message) { + client.callwords.forEach(testCallword); + + function testCallword(item) + { + if(item !== "" && message.includes(item)) + { + viewport.sfxaudio.pause(); + viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; + viewport.sfxaudio.play(); + } + } +} + + + /** * Triggered when the music search bar is changed * @param {MouseEvent} event -- cgit