LuminaWebsite/admin/bot.php
Maaxxs 8b59cb503b DACH Elyos: the Consilium Elyseum is now called DACH Elyos across the website
Asked for: "das consilium elyseum wurde umbenannt zu DACH Elyos. pass das bitte an auf der website".

- CONSILIUM_NAME is 'DACH Elyos', and every visible text follows it: sidebar, the alliance page, member tab, raid
  area, calendar audience and badge, iCal note, map live sessions and share buttons, admin pages (Verwaltung ->
  DACH Elyos, Discord-Bot, Berechtigungsgruppen), flash messages, log entries, permission descriptions (synced to
  the database by schema_sync_core_permissions()) and the privacy page.
- The name takes no article, so the sentences around it changed too: "von DACH Elyos", "in DACH Elyos", "für DACH
  Elyos" instead of "des Consiliums", "im Consilium", "für das Consilium". The bot channel label is now
  "Raid-Kanal DACH Elyos".
- Internal names stay "consilium": permission keys, tables, settings, files and URLs (?bereich=consilium,
  ?tab=consilium), so nothing in the database or in existing links changes. includes/consilium.php says so.
- README: section renamed to "DACH Elyos" (anchor #dach-elyos).
- No patch note (alliance topics stay out of them). The bot's two "Consilium" error texts in live_tactics.py never
  reach the page - the map only reads the status code - so the bot needs no update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 14:15:10 +02:00

203 lines
10 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Verwaltung -> Discord-Bot: Kanaele, Premade-Uebersicht und Melde-Panel, Raid-Nachrichten abgleichen
* (includes/discord_bot.php). Ersetzt die Slash-Befehle, die es im Bot seit dem Umbau (09/2026) nicht mehr gibt.
*/
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/../includes/discord_bot.php';
require_once __DIR__ . '/../includes/consilium.php';
require_permission('bot.manage');
$settings = [];
$channels = [];
$guildRoles = [];
$apiError = null;
try {
$settings = discord_bot_settings();
$channels = fetch_guild_channels();
$guildRoles = fetch_guild_roles();
} catch (Throwable $e) {
$apiError = $e->getMessage();
}
// Server des Consilium Elyseum (verbuendete Legionen): Die Consilium-Raids stehen in einem Kanal dort
$consiliumGuild = consilium_guild_id();
$consiliumChannels = [];
$consiliumError = null;
if ($apiError === null && $consiliumGuild !== '') {
try {
$consiliumChannels = fetch_guild_channels($consiliumGuild);
} catch (Throwable $e) {
$consiliumError = $e->getMessage();
}
}
/**
* Auswahl eines Textkanals. Kanaele, in denen der Bot nicht posten darf, sind ausgegraut.
*
* @param array<int, array<string, mixed>> $channels
*/
function bot_channel_select(string $name, string $id, array $channels, string $selected, string $placeholder): void
{
?>
<select name="<?= e($name) ?>" id="<?= e($id) ?>">
<option value=""<?= $selected === '' ? ' selected' : '' ?>><?= e($placeholder) ?></option>
<?php foreach ($channels as $channel): ?>
<?php $cid = (string) ($channel['channel_id'] ?? ''); ?>
<option value="<?= e($cid) ?>"<?= $cid === $selected ? ' selected' : '' ?><?= empty($channel['can_post']) && $cid !== $selected ? ' disabled' : '' ?>>
#<?= e((string) ($channel['name'] ?? '')) ?><?php if (!empty($channel['category'])): ?> (<?= e((string) $channel['category']) ?>)<?php endif; ?><?= empty($channel['can_post']) ? ' – Bot darf hier nicht posten' : '' ?>
</option>
<?php endforeach; ?>
</select>
<?php
}
/**
* Auswahl einer Rolle des Servers (fuer das Melde-Panel).
*
* @param array<int, array<string, mixed>> $roles
*/
function bot_role_select(string $name, string $id, array $roles, string $selected, string $placeholder): void
{
?>
<select name="<?= e($name) ?>" id="<?= e($id) ?>">
<option value=""<?= $selected === '' ? ' selected' : '' ?>><?= e($placeholder) ?></option>
<?php foreach ($roles as $role): ?>
<?php $rid = (string) ($role['role_id'] ?? ''); ?>
<option value="<?= e($rid) ?>"<?= $rid === $selected ? ' selected' : '' ?>>@<?= e((string) ($role['name'] ?? '')) ?></option>
<?php endforeach; ?>
</select>
<?php
}
$pageTitle = 'Discord-Bot';
include __DIR__ . '/../includes/header.php';
?>
<div class="panel">
<h1>Discord-Bot</h1>
<p class="text-muted">
Im Discord wird nichts mehr erstellt oder verwaltet – Raids, Premades, Events, Aktivitätschecks und
Reports laufen über die Website. Der Bot zeigt an, erinnert und nimmt Raid-Anmeldungen und Meldungen
entgegen. Hier legst du fest, wohin er postet.
</p>
</div>
<?php if ($apiError !== null): ?>
<div class="panel">
<div class="flash flash-error">Der Bot ist gerade nicht erreichbar: <?= e($apiError) ?></div>
</div>
<?php else: ?>
<div class="panel">
<h2>Kanäle</h2>
<form method="post" action="/admin/bot_action.php" class="bot-admin-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="channels">
<?php foreach (DISCORD_BOT_CHANNELS as $key => [$label, $hint]): ?>
<?php // Consilium-Raids: Kanal auf dem Server des Consiliums, sobald einer eingetragen ist ?>
<?php $onConsilium = $key === 'consilium_raid_channel' && $consiliumGuild !== ''; ?>
<div>
<label for="bot-<?= e($key) ?>"><?= e($label) ?><?= $onConsilium ? ' <span class="text-muted">(Server von ' . e(CONSILIUM_NAME) . ')</span>' : '' ?></label>
<?php bot_channel_select($key, 'bot-' . $key, $onConsilium ? $consiliumChannels : $channels, $settings[$key] ?? '', '– nicht festgelegt –'); ?>
<div class="field-hint"><?= e($hint) ?></div>
<?php if ($onConsilium && $consiliumError !== null): ?>
<div class="field-hint">⚠️ Die Kanäle des Servers von <?= e(CONSILIUM_NAME) ?> lassen sich nicht laden – ist der Bot dort Mitglied? (<?= e($consiliumError) ?>)</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<div class="actions">
<button type="submit">Kanäle speichern</button>
</div>
</form>
</div>
<div class="panel">
<h2>Discord-Server von <?= e(CONSILIUM_NAME) ?></h2>
<p class="text-muted">
Der Server der verbündeten Legionen. Wer dort eine Rolle hat, kann sich auf der Website anmelden und sieht den
Bereich <?= e(CONSILIUM_NAME) ?> – welche Gruppe zu welcher Rolle gehört, legst du unter
<a href="/admin/roles.php">Berechtigungsgruppen</a> fest. Der Bot muss auf dem Server sein (für die
Raids von <?= e(CONSILIUM_NAME) ?> und um zu bemerken, wer den Server verlässt).
</p>
<form method="post" action="/admin/bot_action.php" class="bot-admin-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="consilium_guild">
<div>
<label for="bot-consilium-guild">Server-ID</label>
<input type="text" id="bot-consilium-guild" name="consilium_guild_id" inputmode="numeric" maxlength="20" value="<?= e($consiliumGuild) ?>" placeholder="z.B. 123456789012345678">
<div class="field-hint">
<?php if ($consiliumGuild === ''): ?>
Kein Server eingetragen – dann gibt es auf der Website nur den Server der Legion.
<?php elseif ($consiliumError === null): ?>
✅ Der Bot ist auf diesem Server.
<?php else: ?>
⚠️ Der Bot ist nicht auf diesem Server oder nicht erreichbar – bitte einladen.
<?php endif; ?>
In Discord: Rechtsklick auf den Server → „Server-ID kopieren“ (Entwicklermodus nötig). Leer lassen, um ihn zu entfernen.
</div>
</div>
<div class="actions">
<button type="submit">Server speichern</button>
</div>
</form>
</div>
<div class="panel">
<h2>Übersichten im Discord</h2>
<p class="text-muted">
Der Bot merkt sich, wo sie stehen. Postest du sie neu, löscht er die bisherige. Was früher per
Befehl im Discord gepostet wurde, kennt er nicht – das nach dem Neu-Posten dort von Hand löschen.
</p>
<div class="bot-panels">
<?php foreach (DISCORD_BOT_PANELS as $kind => [$label, $path, $hint]): ?>
<?php $current = $settings[$kind === 'premades' ? 'premade_panel_channel' : 'report_panel_channel'] ?? ''; ?>
<form method="post" action="/admin/bot_action.php" class="bot-admin-form bot-panel">
<?= csrf_field() ?>
<input type="hidden" name="action" value="panel">
<input type="hidden" name="kind" value="<?= e($kind) ?>">
<h3><?= e($label) ?></h3>
<p class="text-muted"><?= e($hint) ?></p>
<p>
<?php if ($current !== ''): ?>
Steht in <strong><?= e(discord_bot_channel_label($current, $channels)) ?></strong>.
<?php else: ?>
<span class="text-muted">Noch nicht über die Website gepostet.</span>
<?php endif; ?>
</p>
<div>
<label for="bot-panel-<?= e($kind) ?>">Kanal</label>
<?php bot_channel_select('channel_id', 'bot-panel-' . $kind, $channels, $current, '– Kanal wählen –'); ?>
</div>
<?php if ($kind === 'reports'): ?>
<div>
<label for="bot-report-ping">Ping beim Posten</label>
<?php bot_role_select('ping_role_id', 'bot-report-ping', $guildRoles, $settings['report_panel_ping_role'] ?? '', '– niemand –'); ?>
<div class="field-hint">Über dem Panel steht „Arieluma @Rolle!“ – das pingt die Rolle einmal beim Posten, z.B. alle Mitglieder. Jedes Neu-Posten pingt wieder.</div>
</div>
<div>
<label for="bot-report-lead">Leitung im Text</label>
<?php bot_role_select('lead_role_id', 'bot-report-lead', $guildRoles, $settings['report_panel_lead_role'] ?? '', '– keine Rolle („die Legionsleitung“) –'); ?>
<div class="field-hint">Wird im Panel erwähnt, ohne Ping – z.B. „die @Sedes Luminis kümmern sich zeitnah um dein Anliegen“.</div>
</div>
<?php endif; ?>
<div class="actions">
<button type="submit" class="button-secondary"><?= $current !== '' ? 'Neu posten' : 'Posten' ?></button>
</div>
</form>
<?php endforeach; ?>
</div>
</div>
<div class="panel">
<h2>Raid-Nachrichten abgleichen</h2>
<p class="text-muted">
Bringt die Nachrichten aller aktiven Raids im Discord auf den Stand der Website und postet fehlende
neu – etwa wenn jemand eine Raid-Nachricht gelöscht hat.
</p>
<form method="post" action="/admin/bot_action.php" class="inline-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="resync">
<button type="submit" class="button-secondary"><?= icon('restore') ?> Jetzt abgleichen</button>
</form>
</div>
<?php endif; ?>
<?php include __DIR__ . '/../includes/footer.php'; ?>