import { Gotify } from "gotify"; import { QueryProtocol, TeamSpeak } from "ts3-nodejs-library"; import { pino } from "pino"; import { GOTIFY_TITLE, GOTIFY_TOKEN, GOTIFY_URL, LOG_LEVEL, MODE, TS3_HOST, TS3_NICKNAME, TS3_PASSWORD, TS3_QUERY_PORT, TS3_SERVER_PORT, TS3_USERNAME, } from "./env"; import type { Mode } from "./types"; import { getModes, ts3gotifyFactory } from "./ts3gotify"; async function main() { const logger = pino({ level: LOG_LEVEL, name: "ts3gotify", }); const gotify = new Gotify({ server: GOTIFY_URL, }); const teamspeak = await TeamSpeak.connect({ host: TS3_HOST, queryport: TS3_QUERY_PORT, serverport: TS3_SERVER_PORT, protocol: QueryProtocol.RAW, username: TS3_USERNAME, password: TS3_PASSWORD, nickname: TS3_NICKNAME, }); logger.info("connected to TS3"); const modeList = getModes(MODE); const enabledModeNames = Object.entries(modeList) .filter(([, value]) => value) .map(([key]) => key); logger.info(`connected to TS3 in modes: ${enabledModeNames.join(", ")}`); const ts3gotify = ts3gotifyFactory( teamspeak, gotify, { app: GOTIFY_TOKEN, title: GOTIFY_TITLE, }, logger ); for (const mode of enabledModeNames) ts3gotify.registerEventListenerForMode(mode as Mode); } main();