aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/checkCallword.ts
blob: f6cffbc507ec68d22bfd93edea3a1a8106c9be41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { client } from "../client";
import { AO_HOST } from "./aoHost";

/**
 * check if the message contains an entry on our callword list
 * @param {string} message
 */
export function checkCallword(message: string, sfxAudio: HTMLAudioElement) {
    client.callwords.forEach(testCallword);
    function testCallword(item: string) {
        if (item !== "" && message.toLowerCase().includes(item.toLowerCase())) {
            sfxAudio.pause();
            sfxAudio.src = `${AO_HOST}sounds/general/sfx-gallery.opus`;
            sfxAudio.play();
        }
    }
}