aboutsummaryrefslogtreecommitdiff
path: root/webAO/client/checkCallword.ts
blob: 795eac9862e44a043c020a87ef04609937dedbbc (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().catch(() => {});
    }
  }
}