Compare commits
38
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7539091ff | ||
|
|
301da179ed | ||
|
|
7bceceb31d | ||
|
|
eee4ceb315 | ||
|
|
c33185db3e | ||
|
|
1da08b256e | ||
|
|
1d627c212a | ||
|
|
e7f595176a | ||
|
|
bfe315d70c | ||
|
|
d2a811f177 | ||
|
|
c69d5548e5 | ||
|
|
af4f036515 | ||
|
|
91213d354f | ||
|
|
4fa4db3640 | ||
|
|
a98a34d769 | ||
|
|
3bfe087b7d | ||
|
|
43ecb8a1ad | ||
|
|
46d1954a6d | ||
|
|
30ec5359b1 | ||
|
|
5527c2ce58 | ||
|
|
1b7c13b592 | ||
|
|
e3a1ed4a63 | ||
|
|
84dad0993c | ||
|
|
3a109883b3 | ||
|
|
85041b2bff | ||
|
|
ea2207899f | ||
|
|
263c7e7b7c | ||
|
|
306b3aa7e5 | ||
|
|
34e5fc7d0e | ||
|
|
8be8b3d879 | ||
|
|
3a74e16bb8 | ||
|
|
f1fc1642ab | ||
|
|
db4a6bedf7 | ||
|
|
7be0d85ab5 | ||
|
|
e304556346 | ||
|
|
bf438511d6 | ||
|
|
f7520a6ca7 | ||
|
|
f08297dd0d |
No files matched your search
@@ -10,6 +10,7 @@ export default function VetoBoard({ state, viewer, act, busy, compact = false })
|
|||||||
const { current } = veto;
|
const { current } = veto;
|
||||||
const [selected, setSelected] = useState(null);
|
const [selected, setSelected] = useState(null);
|
||||||
useEffect(() => setSelected(null), [current?.index]);
|
useEffect(() => setSelected(null), [current?.index]);
|
||||||
|
const left = useCountdown(veto.remainingMs);
|
||||||
|
|
||||||
const mapsById = Object.fromEntries(state.maps.map((m) => [m.id, m]));
|
const mapsById = Object.fromEntries(state.maps.map((m) => [m.id, m]));
|
||||||
const yourTurn = !!current && viewer.isCaptain && viewer.team === current.team;
|
const yourTurn = !!current && viewer.isCaptain && viewer.team === current.team;
|
||||||
@@ -38,6 +39,7 @@ export default function VetoBoard({ state, viewer, act, busy, compact = false })
|
|||||||
? 'Live-Ansicht – nur Captains können wählen.'
|
? 'Live-Ansicht – nur Captains können wählen.'
|
||||||
: 'Das andere Team ist am Zug.'}
|
: 'Das andere Team ist am Zug.'}
|
||||||
</span>
|
</span>
|
||||||
|
{left !== null && <span className="turn-timer">Noch {Math.ceil(left / 1000)} s</span>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!current && veto.done && !compact && <div className="turn turn-done">Veto abgeschlossen</div>}
|
{!current && veto.done && !compact && <div className="turn turn-done">Veto abgeschlossen</div>}
|
||||||
@@ -129,3 +131,16 @@ function statusText(m, teams) {
|
|||||||
default: return 'Verfügbar';
|
default: return 'Verfügbar';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Verbleibende Zeit des Veto-Schritts: der Server setzt sie bei jeder Änderung, danach zählt die Anzeige lokal herunter. */
|
||||||
|
function useCountdown(ms) {
|
||||||
|
const [left, setLeft] = useState(ms ?? null);
|
||||||
|
useEffect(() => {
|
||||||
|
setLeft(ms ?? null);
|
||||||
|
if (ms == null) return undefined;
|
||||||
|
const started = Date.now();
|
||||||
|
const t = setInterval(() => setLeft(Math.max(0, ms - (Date.now() - started))), 250);
|
||||||
|
return () => clearInterval(t);
|
||||||
|
}, [ms]);
|
||||||
|
return left;
|
||||||
|
}
|
||||||
@@ -29,7 +29,6 @@ export default function AdminPage() {
|
|||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [notice, setNotice] = useState(null);
|
const [notice, setNotice] = useState(null);
|
||||||
const [busy, setBusy] = useState(null);
|
const [busy, setBusy] = useState(null);
|
||||||
const [tab, setTab] = useState('matches');
|
|
||||||
|
|
||||||
const logout = useCallback(() => {
|
const logout = useCallback(() => {
|
||||||
api('/admin/logout', { method: 'POST', token }).catch(() => {});
|
api('/admin/logout', { method: 'POST', token }).catch(() => {});
|
||||||
@@ -93,22 +92,17 @@ export default function AdminPage() {
|
|||||||
<button className="btn btn-sm" onClick={logout}>Abmelden</button>
|
<button className="btn btn-sm" onClick={logout}>Abmelden</button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<nav className="admin-tabs" aria-label="Admin-Bereiche">
|
{token && <NotificationSettings token={token} setNotice={setNotice} />}
|
||||||
<button className={`admin-tab ${tab === 'matches' ? 'is-active' : ''}`} onClick={() => setTab('matches')}>Matches</button>
|
|
||||||
<button className={`admin-tab ${tab === 'settings' ? 'is-active' : ''}`} onClick={() => setTab('settings')}>Einstellungen</button>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
{tab === 'settings' && token && <NotificationSettings token={token} setNotice={setNotice} />}
|
|
||||||
{notice && <div className={`toast toast-${notice.tone}`} role="status">{notice.text}</div>}
|
{notice && <div className={`toast toast-${notice.tone}`} role="status">{notice.text}</div>}
|
||||||
{error && <div className="alert alert-error">{error}</div>}
|
{error && <div className="alert alert-error">{error}</div>}
|
||||||
{tab === 'matches' && matches === null && !error && <p className="muted">Lade Matches …</p>}
|
{matches === null && !error && <p className="muted">Lade Matches …</p>}
|
||||||
{tab === 'matches' && matches && matches.length === 0 && <p className="muted">Noch keine Matches.</p>}
|
{matches && matches.length === 0 && <p className="muted">Noch keine Matches.</p>}
|
||||||
|
|
||||||
{tab === 'matches' && <div className="admin-list">
|
<div className="admin-list">
|
||||||
{matches?.map((m) => (
|
{matches?.map((m) => (
|
||||||
<MatchAdminCard key={m.id} m={m} run={run} busy={busy} token={token} reload={load} setNotice={setNotice} />
|
<MatchAdminCard key={m.id} m={m} run={run} busy={busy} token={token} reload={load} setNotice={setNotice} />
|
||||||
))}
|
))}
|
||||||
</div>}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -518,8 +518,4 @@ input:focus, select:focus { border-color: var(--link); outline: none; }
|
|||||||
.admin-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-bottom: 12px; }
|
.admin-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-bottom: 12px; }
|
||||||
.admin-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
|
.admin-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
|
||||||
|
|
||||||
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
|
.turn-timer { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||||
.admin-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font: inherit; cursor: pointer; }
|
|
||||||
.admin-tab:hover { color: var(--text); }
|
|
||||||
.admin-tab.is-active { color: var(--text); border-bottom-color: var(--primary); }
|
|
||||||
|
|
||||||
@@ -81,8 +81,7 @@ export function createAdminRouter({ service, manager, config }) {
|
|||||||
router.put('/notifications', requireAdmin, wrap((req) => service.setNotificationEvents(req.body?.events)));
|
router.put('/notifications', requireAdmin, wrap((req) => service.setNotificationEvents(req.body?.events)));
|
||||||
router.post('/notifications/test', requireAdmin, wrap(async () => {
|
router.post('/notifications/test', requireAdmin, wrap(async () => {
|
||||||
if (!service.notifier.enabled) throw new HttpError(409, 'Kein Discord-Webhook eingerichtet (DISCORD_WEBHOOK_URL)', 'not_configured');
|
if (!service.notifier.enabled) throw new HttpError(409, 'Kein Discord-Webhook eingerichtet (DISCORD_WEBHOOK_URL)', 'not_configured');
|
||||||
const test = { embeds: [{ title: '🧪 Testmeldung', description: 'Die Verbindung zu CS2 Mapveto funktioniert.', color: 0x3b82f6 }] };
|
if (!(await service.notifier.send('Testmeldung aus CS2 Mapveto'))) {
|
||||||
if (!(await service.notifier.send(test))) {
|
|
||||||
throw new HttpError(502, 'Discord hat die Meldung nicht angenommen (siehe Log)', 'send_failed');
|
throw new HttpError(502, 'Discord hat die Meldung nicht angenommen (siehe Log)', 'send_failed');
|
||||||
}
|
}
|
||||||
return { ok: true };
|
return { ok: true };
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export function createApp(config, { adapter: adapterOverride, logger = console }
|
|||||||
const adapter = adapterOverride ?? createServerAdapter(config, { getUsedPorts: () => manager.usedPorts() });
|
const adapter = adapterOverride ?? createServerAdapter(config, { getUsedPorts: () => manager.usedPorts() });
|
||||||
manager = new ServerManager({ db, service, adapter, config, logger });
|
manager = new ServerManager({ db, service, adapter, config, logger });
|
||||||
manager.init();
|
manager.init();
|
||||||
|
service.startVetoTimer();
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
if (config.trustProxy) app.set('trust proxy', 1);
|
if (config.trustProxy) app.set('trust proxy', 1);
|
||||||
@@ -54,6 +55,7 @@ export function createApp(config, { adapter: adapterOverride, logger = console }
|
|||||||
},
|
},
|
||||||
async close() {
|
async close() {
|
||||||
manager.stopLoops();
|
manager.stopLoops();
|
||||||
|
service.stopVetoTimer();
|
||||||
// Laufende Server-Aktionen (Start, Konfiguration) kurz abwarten, bevor die Datenbank schließt
|
// Laufende Server-Aktionen (Start, Konfiguration) kurz abwarten, bevor die Datenbank schließt
|
||||||
await manager.idle(5000);
|
await manager.idle(5000);
|
||||||
io.disposeRealtime();
|
io.disposeRealtime();
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export function loadConfig(overrides = {}) {
|
|||||||
maxLifetimeHours: int('SERVER_MAX_LIFETIME_HOURS', 8),
|
maxLifetimeHours: int('SERVER_MAX_LIFETIME_HOURS', 8),
|
||||||
statusPollSeconds: int('SERVER_STATUS_POLL_SECONDS', 5),
|
statusPollSeconds: int('SERVER_STATUS_POLL_SECONDS', 5),
|
||||||
reaperIntervalSeconds: int('SERVER_REAPER_INTERVAL_SECONDS', 60),
|
reaperIntervalSeconds: int('SERVER_REAPER_INTERVAL_SECONDS', 60),
|
||||||
|
// Frist pro Veto-Schritt in Sekunden, danach führt das Backend den Schritt automatisch aus. 0 = keine Frist
|
||||||
|
vetoStepSeconds: int('VETO_STEP_SECONDS', 30),
|
||||||
|
|
||||||
match: {
|
match: {
|
||||||
tvDelaySeconds: int('CS2_TV_DELAY', 90),
|
tvDelaySeconds: int('CS2_TV_DELAY', 90),
|
||||||
|
|||||||
@@ -27,14 +27,12 @@ export function createDiscordNotifier(url, { fetchImpl = fetch, logger = console
|
|||||||
return {
|
return {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
/** Liefert true, wenn Discord die Nachricht angenommen hat. */
|
/** Liefert true, wenn Discord die Nachricht angenommen hat. */
|
||||||
async send(message) {
|
async send(content) {
|
||||||
// Text oder vollständige Discord-Payload (z. B. mit embeds)
|
|
||||||
const payload = typeof message === 'string' ? { content: message.slice(0, MAX_LENGTH) } : message;
|
|
||||||
try {
|
try {
|
||||||
const res = await fetchImpl(url, {
|
const res = await fetchImpl(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify({ content: content.slice(0, MAX_LENGTH) }),
|
||||||
signal: AbortSignal.timeout(TIMEOUT_MS),
|
signal: AbortSignal.timeout(TIMEOUT_MS),
|
||||||
});
|
});
|
||||||
if (res.ok) return true;
|
if (res.ok) return true;
|
||||||
|
|||||||
+64
-40
@@ -341,16 +341,63 @@ export class MatchService extends EventEmitter {
|
|||||||
.run(firstTeam, this.now(), this.now(), match.id);
|
.run(firstTeam, this.now(), this.now(), match.id);
|
||||||
const how = match.veto_start === 'coin' ? 'per Münzwurf ausgelost' : 'vom Organisator festgelegt';
|
const how = match.veto_start === 'coin' ? 'per Münzwurf ausgelost' : 'vom Organisator festgelegt';
|
||||||
this.log(match.id, 'veto', `Veto gestartet – ${this.teamName(match, firstTeam)} beginnt (${how})`);
|
this.log(match.id, 'veto', `Veto gestartet – ${this.teamName(match, firstTeam)} beginnt (${how})`);
|
||||||
this.notify('veto_start', match.id, {
|
this.notify('veto_start', match.id, `Veto gestartet: ${this.matchTitle(match.id)}, ${this.teamName(match, firstTeam)} beginnt`);
|
||||||
title: '🎮 Veto gestartet',
|
|
||||||
description: `**${this.matchTitle(match.id)}**`,
|
|
||||||
color: 0x3b82f6,
|
|
||||||
fields: [{ name: 'Beginnt', value: this.teamName(match, firstTeam), inline: true }],
|
|
||||||
});
|
|
||||||
})();
|
})();
|
||||||
this.changed(viewer.matchId);
|
this.changed(viewer.matchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ablaufzeitpunkt des aktuellen Veto-Schritts (ms), null wenn keine Frist gilt. */
|
||||||
|
vetoDeadline(match) {
|
||||||
|
if (!this.config.vetoStepSeconds || match.status !== 'veto') return null;
|
||||||
|
const actions = this.vetoActions(match.id);
|
||||||
|
const since = actions.length ? actions[actions.length - 1].created_at : match.veto_started_at;
|
||||||
|
return since == null ? null : since + this.config.vetoStepSeconds * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
vetoRemainingMs(match) {
|
||||||
|
const deadline = this.vetoDeadline(match);
|
||||||
|
return deadline === null ? null : Math.max(0, deadline - this.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Führt den aktuellen Veto-Schritt für das Team am Zug aus: zufällige Map bzw. zufällige Seite. */
|
||||||
|
autoVetoStep(match) {
|
||||||
|
const state = this.vetoState(match);
|
||||||
|
if (state.done || !state.current) return;
|
||||||
|
const { type, team, index } = state.current;
|
||||||
|
const pick = (list) => list[Math.floor(Math.random() * list.length)];
|
||||||
|
const viewer = {
|
||||||
|
matchId: match.id, role: 'captain', isOrganizer: false, isCaptain: true, isSpectator: false, playerId: null, team,
|
||||||
|
};
|
||||||
|
const action = type === 'side'
|
||||||
|
? { stepIndex: index, side: pick(['CT', 'T']) }
|
||||||
|
: { stepIndex: index, map: pick(state.maps.filter((m) => m.status === 'available')).id };
|
||||||
|
this.log(match.id, 'veto', `Zeit abgelaufen – ${this.teamName(match, team)} wird automatisch vertreten`);
|
||||||
|
this.vetoAction(viewer, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Läuft die Frist eines Veto-Schritts ab, führt das Backend den Schritt aus. */
|
||||||
|
autoVetoTimeouts() {
|
||||||
|
for (const match of this.db.prepare("SELECT * FROM matches WHERE status = 'veto'").all()) {
|
||||||
|
const deadline = this.vetoDeadline(match);
|
||||||
|
if (deadline === null || this.now() < deadline) continue;
|
||||||
|
try {
|
||||||
|
this.autoVetoStep(match);
|
||||||
|
} catch (err) {
|
||||||
|
this.log(match.id, 'veto', `Automatischer Schritt fehlgeschlagen: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
startVetoTimer() {
|
||||||
|
if (!this.config.vetoStepSeconds || this.vetoTimer) return;
|
||||||
|
this.vetoTimer = setInterval(() => this.autoVetoTimeouts(), 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
stopVetoTimer() {
|
||||||
|
clearInterval(this.vetoTimer);
|
||||||
|
this.vetoTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
vetoAction(viewer, { stepIndex, map, side }) {
|
vetoAction(viewer, { stepIndex, map, side }) {
|
||||||
this.require(viewer, 'captain');
|
this.require(viewer, 'captain');
|
||||||
let finished = false;
|
let finished = false;
|
||||||
@@ -524,16 +571,8 @@ export class MatchService extends EventEmitter {
|
|||||||
const winner = state.winner ? this.teamName(match, state.winner) : 'Unentschieden';
|
const winner = state.winner ? this.teamName(match, state.winner) : 'Unentschieden';
|
||||||
this.log(matchId, 'score',
|
this.log(matchId, 'score',
|
||||||
`Map ${row.number} (${this.mapName(match, row.map)}) beendet: ${match.team_a_name} ${state.score.A}:${state.score.B} ${match.team_b_name} – Sieger: ${winner}`);
|
`Map ${row.number} (${this.mapName(match, row.map)}) beendet: ${match.team_a_name} ${state.score.A}:${state.score.B} ${match.team_b_name} – Sieger: ${winner}`);
|
||||||
this.notify('map_end', matchId, {
|
this.notify('map_end', matchId, `${this.matchTitle(matchId)}
|
||||||
title: '🗺️ Map beendet',
|
Map ${row.number} (${this.mapName(match, row.map)}) beendet: ${state.score.A}:${state.score.B}, Sieger ${winner}`);
|
||||||
description: `**${this.matchTitle(matchId)}**`,
|
|
||||||
color: 0xf59e0b,
|
|
||||||
fields: [
|
|
||||||
{ name: `Map ${row.number}`, value: this.mapName(match, row.map), inline: true },
|
|
||||||
{ name: 'Stand', value: `${state.score.A} : ${state.score.B}`, inline: true },
|
|
||||||
{ name: 'Sieger', value: winner, inline: true },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
if (ended) {
|
if (ended) {
|
||||||
@@ -542,18 +581,8 @@ export class MatchService extends EventEmitter {
|
|||||||
const needed = Math.floor(BEST_OF[ended.match.format] / 2) + 1;
|
const needed = Math.floor(BEST_OF[ended.match.format] / 2) + 1;
|
||||||
const decided = score.A >= needed ? 'A' : score.B >= needed ? 'B' : null;
|
const decided = score.A >= needed ? 'A' : score.B >= needed ? 'B' : null;
|
||||||
if (decided) this.log(matchId, 'score', `Serie entschieden: ${this.teamName(ended.match, decided)} gewinnt ${score[decided]}:${score[decided === 'A' ? 'B' : 'A']}`);
|
if (decided) this.log(matchId, 'score', `Serie entschieden: ${this.teamName(ended.match, decided)} gewinnt ${score[decided]}:${score[decided === 'A' ? 'B' : 'A']}`);
|
||||||
if (decided) {
|
if (decided) this.notify('series_end', matchId, `${this.matchTitle(matchId)}
|
||||||
const loser = decided === 'A' ? 'B' : 'A';
|
Serie entschieden: ${this.teamName(ended.match, decided)} gewinnt ${score[decided]}:${score[decided === 'A' ? 'B' : 'A']}`);
|
||||||
this.notify('series_end', matchId, {
|
|
||||||
title: '🏆 Serie entschieden',
|
|
||||||
description: `**${this.matchTitle(matchId)}**`,
|
|
||||||
color: 0x22c55e,
|
|
||||||
fields: [
|
|
||||||
{ name: 'Sieger', value: this.teamName(ended.match, decided), inline: true },
|
|
||||||
{ name: 'Serienstand', value: `${score[decided]} : ${score[loser]}`, inline: true },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const hasNext = maps.some((m) => m.number === ended.row.number + 1);
|
const hasNext = maps.some((m) => m.number === ended.row.number + 1);
|
||||||
this.changed(matchId);
|
this.changed(matchId);
|
||||||
this.emit('mapEnded', { matchId, number: ended.row.number, decided, hasNext });
|
this.emit('mapEnded', { matchId, number: ended.row.number, decided, hasNext });
|
||||||
@@ -585,12 +614,8 @@ export class MatchService extends EventEmitter {
|
|||||||
this.db.prepare("UPDATE series_maps SET status = 'done' WHERE match_id = ? AND status IN ('live','next')").run(match.id);
|
this.db.prepare("UPDATE series_maps SET status = 'done' WHERE match_id = ? AND status IN ('live','next')").run(match.id);
|
||||||
}
|
}
|
||||||
this.log(match.id, 'status', message ?? (status === 'finished' ? 'Match abgeschlossen' : 'Match abgebrochen'));
|
this.log(match.id, 'status', message ?? (status === 'finished' ? 'Match abgeschlossen' : 'Match abgebrochen'));
|
||||||
const finished = status === 'finished';
|
this.notify('match_closed', match.id, `${this.matchTitle(match.id)}
|
||||||
this.notify('match_closed', match.id, {
|
${message ?? (status === 'finished' ? 'Match abgeschlossen' : 'Match abgebrochen')}`);
|
||||||
title: finished ? '✅ Match abgeschlossen' : '⛔ Match abgebrochen',
|
|
||||||
description: `**${this.matchTitle(match.id)}**${message ? `\n${message}` : ''}`,
|
|
||||||
color: finished ? 0x6b7280 : 0x9ca3af,
|
|
||||||
});
|
|
||||||
this.setStatus(match.id, status);
|
this.setStatus(match.id, status);
|
||||||
this.emit('closed', match.id);
|
this.emit('closed', match.id);
|
||||||
}
|
}
|
||||||
@@ -637,13 +662,11 @@ export class MatchService extends EventEmitter {
|
|||||||
return this.notificationSettings();
|
return this.notificationSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Meldung als Discord-Embed. Ohne Stream-Schlüssel ist der Titel ein Link auf die Match-Übersicht. */
|
notify(type, matchId, text) {
|
||||||
notify(type, matchId, embed) {
|
|
||||||
if (!this.notifier.enabled || !this.notificationSettings().events[type]) return;
|
if (!this.notifier.enabled || !this.notificationSettings().events[type]) return;
|
||||||
const url = this.config.streamKey ? undefined : `${this.config.publicUrl}/stream/match/${matchId}`;
|
const link = this.config.streamKey ? '' : `
|
||||||
this.notifier.send({
|
${this.config.publicUrl}/stream/match/${matchId}`;
|
||||||
embeds: [{ ...embed, url, timestamp: new Date(this.now()).toISOString(), footer: { text: 'CS2 Mapveto' } }],
|
this.notifier.send(`${text}${link}`);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log(matchId, type, message) {
|
log(matchId, type, message) {
|
||||||
@@ -841,6 +864,7 @@ export class MatchService extends EventEmitter {
|
|||||||
steps: veto.steps,
|
steps: veto.steps,
|
||||||
maps: veto.maps,
|
maps: veto.maps,
|
||||||
current: match.status === 'veto' ? veto.current : null,
|
current: match.status === 'veto' ? veto.current : null,
|
||||||
|
remainingMs: this.vetoRemainingMs(match),
|
||||||
done: veto.done,
|
done: veto.done,
|
||||||
history: actions.map((a) => ({
|
history: actions.map((a) => ({
|
||||||
index: a.idx,
|
index: a.idx,
|
||||||
|
|||||||
@@ -265,11 +265,7 @@ export class ServerManager {
|
|||||||
} else if (status.state === 'failed') {
|
} else if (status.state === 'failed') {
|
||||||
Object.assign(fields, { status: current.status === 'starting' ? 'start_failed' : 'failed', message: status.message });
|
Object.assign(fields, { status: current.status === 'starting' ? 'start_failed' : 'failed', message: status.message });
|
||||||
this.service.log(matchId, 'server', `Server-Fehler: ${status.message}`);
|
this.service.log(matchId, 'server', `Server-Fehler: ${status.message}`);
|
||||||
this.service.notify('server_error', matchId, {
|
this.service.notify('server_error', matchId, `Server-Fehler bei ${this.service.matchTitle(matchId)}: ${status.message}`);
|
||||||
title: '⚠️ Serverfehler',
|
|
||||||
description: `**${this.service.matchTitle(matchId)}**\n${status.message}`,
|
|
||||||
color: 0xdc2626,
|
|
||||||
});
|
|
||||||
} else if (status.state === 'stopped') {
|
} else if (status.state === 'stopped') {
|
||||||
Object.assign(fields, { status: 'stopped', stopped_at: Date.now(), message: status.message ?? 'Server wurde extern beendet' });
|
Object.assign(fields, { status: 'stopped', stopped_at: Date.now(), message: status.message ?? 'Server wurde extern beendet' });
|
||||||
this.service.log(matchId, 'server', 'Server wurde außerhalb der Anwendung beendet');
|
this.service.log(matchId, 'server', 'Server wurde außerhalb der Anwendung beendet');
|
||||||
@@ -392,17 +388,7 @@ export class ServerManager {
|
|||||||
throw new HttpError(502, `Befehl konnte nicht gesendet werden: ${err.message}`, 'server_error');
|
throw new HttpError(502, `Befehl konnte nicht gesendet werden: ${err.message}`, 'server_error');
|
||||||
}
|
}
|
||||||
this.service.log(viewer.matchId, 'server', this.adapter.simulated ? 'Aufwärmphase beendet (simuliert)' : 'Aufwärmphase beendet – Match startet');
|
this.service.log(viewer.matchId, 'server', this.adapter.simulated ? 'Aufwärmphase beendet (simuliert)' : 'Aufwärmphase beendet – Match startet');
|
||||||
// CSTV-Zugang für Zuschauer, gleiche Form wie im Zuschauerbereich der Webseite
|
this.service.notify('match_start', viewer.matchId, `Match gestartet: ${this.service.matchTitle(viewer.matchId)}`);
|
||||||
const fields = [];
|
|
||||||
if (this.config.match.tvEnabled && row.tv_port) {
|
|
||||||
fields.push({ name: '📺 CSTV', value: `\`password ${row.tv_password}; connect ${row.host}:${row.tv_port}\`` });
|
|
||||||
}
|
|
||||||
this.service.notify('match_start', viewer.matchId, {
|
|
||||||
title: '🔴 Match läuft',
|
|
||||||
description: `**${this.service.matchTitle(viewer.matchId)}**`,
|
|
||||||
color: 0xef4444,
|
|
||||||
fields,
|
|
||||||
});
|
|
||||||
if (this.adapter.simulated) this.startDemoSimulation(viewer.matchId);
|
if (this.adapter.simulated) this.startDemoSimulation(viewer.matchId);
|
||||||
this.service.changed(viewer.matchId);
|
this.service.changed(viewer.matchId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user