Elyos Allianz: Raids, Kanäle und Rollen kommen von Siel

Neue Raids der Elyos Allianz postet Siel (config.php: siel_api), die Website holt die Raids
beider Bots und schickt Anfragen zu einem Raid an den Bot, der ihn gepostet hat. Kanäle und
Rollen des Servers der Elyos Allianz liefert Siel. Premades nur noch bei Legions-Raids.
Ohne siel_api-Block bleibt alles wie vorher bei Nezekan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-29 07:58:44 +02:00
parent 3a27c214c6
commit 74fdf2bbf8
12 changed files with 203 additions and 36 deletions

View file

@ -1569,6 +1569,17 @@ Rolle hat, sieht auf der Website den Bereich Elyos Allianz; Mitglieder verbünde
der Legion. Der angezeigte Name steht in `CONSILIUM_NAME` - im Code, in Rechten, Tabellen, Einstellungen und Adressen der Legion. Der angezeigte Name steht in `CONSILIUM_NAME` - im Code, in Rechten, Tabellen, Einstellungen und Adressen
heißt alles weiter `consilium`. Code: `includes/consilium.php`, Verwaltung `admin/consilium.php`. heißt alles weiter `consilium`. Code: `includes/consilium.php`, Verwaltung `admin/consilium.php`.
- **Siel, der Bot der Elyos Allianz** (seit 29.09.2026; Code `E:\DiscordBots\SielBot` → `/root/sielbot`, Verwaltung auf
https://bot.lumina-ascendens.de): postet die Raids der Elyos Allianz auf deren Server und liefert dessen Kanäle und
Rollen. Die Website spricht ihn über `config.php` → `siel_api` an (`url` = `https://bot.lumina-ascendens.de/website-api/raids`,
`key` = `WEBSITE_API_KEY` aus `/root/sielbot/.env`). Fehlt der Block, macht Nezekan alles wie vorher.
`raids_fetch_combined()` holt die Raids beider Bots (Feld `bot`: `nezekan`/`siel`, Raids von Siel sind immer
Elyos Allianz), `raid_backend_request()` schickt Anfragen zu einem Raid an den Bot, der ihn gepostet hat (bei 404 an
den anderen), `guilds_api_request()` fragt für den Server der Elyos Allianz Siel. Raids, die Nezekan noch gepostet
hat, laufen dort zu Ende. Premades gibt es bei Raids der Elyos Allianz nicht. Austritte und den 30-Minuten-Abgleich
(`bot_api.php`, `member_left`/`legion_sync`) meldet ebenfalls Siel - für beide Server, er ist dafür auch auf dem
Legionsserver (ohne Rechte, dort sonst ohne Funktion).
- **Zwei Discord-Server:** der der Legion (`config.php`) und der von Elyos Allianz (`settings.consilium_guild_id`, - **Zwei Discord-Server:** der der Legion (`config.php`) und der von Elyos Allianz (`settings.consilium_guild_id`,
Verwaltung → Discord-Bot; `consilium_guild_id()`). Die Rolle einer Berechtigungsgruppe liegt auf einem von beiden Verwaltung → Discord-Bot; `consilium_guild_id()`). Die Rolle einer Berechtigungsgruppe liegt auf einem von beiden
(`roles.discord_guild_id`, NULL = Legion) und wird mit diesem Server abgeglichen - beim Login und alle paar Minuten (`roles.discord_guild_id`, NULL = Legion) und wird mit diesem Server abgeglichen - beim Login und alle paar Minuten

View file

@ -100,7 +100,7 @@ include __DIR__ . '/../includes/header.php';
<?php bot_channel_select($key, 'bot-' . $key, $onConsilium ? $consiliumChannels : $channels, $settings[$key] ?? '', '– nicht festgelegt –'); ?> <?php bot_channel_select($key, 'bot-' . $key, $onConsilium ? $consiliumChannels : $channels, $settings[$key] ?? '', '– nicht festgelegt –'); ?>
<div class="field-hint"><?= e($hint) ?></div> <div class="field-hint"><?= e($hint) ?></div>
<?php if ($onConsilium && $consiliumError !== null): ?> <?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> <div class="field-hint">⚠️ Die Kanäle des Servers von <?= e(CONSILIUM_NAME) ?> lassen sich nicht laden – ist <?= siel_api_config() !== null ? 'Siel' : 'der Bot' ?> dort Mitglied? (<?= e($consiliumError) ?>)</div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
@ -115,8 +115,15 @@ include __DIR__ . '/../includes/header.php';
<p class="text-muted"> <p class="text-muted">
Der Server der verbündeten Legionen. Wer dort eine Rolle hat, kann sich auf der Website anmelden und sieht den 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 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 <a href="/admin/roles.php">Berechtigungsgruppen</a> fest.
Raids von <?= e(CONSILIUM_NAME) ?> und um zu bemerken, wer den Server verlässt). <?php if (siel_api_config() !== null): ?>
Dort arbeitet Siel, der Bot der <?= e(CONSILIUM_NAME) ?> (Verwaltung auf
<a href="https://bot.lumina-ascendens.de" target="_blank" rel="noopener">bot.lumina-ascendens.de</a>):
Er postet die Raids von <?= e(CONSILIUM_NAME) ?> und bemerkt, wer einen der Server verlässt.
<?php else: ?>
Der Bot muss auf dem Server sein (für die Raids von <?= e(CONSILIUM_NAME) ?> und um zu bemerken, wer den
Server verlässt).
<?php endif; ?>
</p> </p>
<form method="post" action="/admin/bot_action.php" class="bot-admin-form"> <form method="post" action="/admin/bot_action.php" class="bot-admin-form">
<?= csrf_field() ?> <?= csrf_field() ?>

View file

@ -84,7 +84,7 @@ try {
} }
set_flash($botThere ? 'success' : 'info', $botThere set_flash($botThere ? 'success' : 'info', $botThere
? 'Server gespeichert.' ? 'Server gespeichert.'
: 'Server gespeichert – der Bot ist aber noch nicht darauf. Bitte einladen, sonst gibt es dort keine Raids von ' . CONSILIUM_NAME . '.'); : 'Server gespeichert – ' . (siel_api_config() !== null ? 'Siel ist' : 'der Bot ist') . ' aber noch nicht darauf. Bitte einladen, sonst gibt es dort keine Raids von ' . CONSILIUM_NAME . '.');
} }
} elseif ($action === 'panel') { } elseif ($action === 'panel') {
$kind = (string) ($_POST['kind'] ?? ''); $kind = (string) ($_POST['kind'] ?? '');

View file

@ -322,7 +322,7 @@ include __DIR__ . '/../includes/header.php';
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<?php if ($consiliumRolesError !== null): ?> <?php if ($consiliumRolesError !== null): ?>
<div class="field-hint">Die Rollen des Servers von <?= e(CONSILIUM_NAME) ?> konnten nicht geladen werden (<?= e($consiliumRolesError) ?>) – ist der Bot dort Mitglied?</div> <div class="field-hint">Die Rollen des Servers von <?= e(CONSILIUM_NAME) ?> konnten nicht geladen werden (<?= e($consiliumRolesError) ?>) – ist <?= siel_api_config() !== null ? 'Siel' : 'der Bot' ?> dort Mitglied?</div>
<?php endif; ?> <?php endif; ?>
<?php else: ?> <?php else: ?>
<input type="text" id="discord_role_id" name="discord_role_id" value="<?= e($currentDiscordRole) ?>" placeholder="Rollen-ID, z.B. 123456789012345678"> <input type="text" id="discord_role_id" name="discord_role_id" value="<?= e($currentDiscordRole) ?>" placeholder="Rollen-ID, z.B. 123456789012345678">

View file

@ -17,7 +17,8 @@
* GET /bot_api.php?action=dues_reminders * GET /bot_api.php?action=dues_reminders
* POST /bot_api.php?action=dues_reminders_done {"results": [{"id": 1, "ok": true}, {"id": 2, "ok": false, "error": "..."}]} * POST /bot_api.php?action=dues_reminders_done {"results": [{"id": 1, "ok": true}, {"id": 2, "ok": false, "error": "..."}]}
* *
* Server verlassen (cogs/legion_members.py im Bot, includes/discord_auth.php): Es zaehlen der Server der Legion und * Server verlassen (cogs/members.py in Siel, dem Bot der Elyos Allianz - bis 29.09.2026 cogs/legion_members.py in
* Nezekan; includes/discord_auth.php): Es zaehlen der Server der Legion und
* der des Consilium Elyseum. Wer einen verlaesst (auch gekickt oder gebannt), verliert dessen Gruppen; ist er auf * der des Consilium Elyseum. Wer einen verlaesst (auch gekickt oder gebannt), verliert dessen Gruppen; ist er auf
* keinem mehr, wird sein Konto deaktiviert, tritt er wieder bei, wartet es wieder auf Freischaltung. Dazu gleicht der * keinem mehr, wird sein Konto deaktiviert, tritt er wieder bei, wartet es wieder auf Freischaltung. Dazu gleicht der
* Bot regelmaessig ab, welche aktiven Konten auf keinem der Server mehr sind. Andere Server zaehlen nicht. * Bot regelmaessig ab, welche aktiven Konten auf keinem der Server mehr sind. Andere Server zaehlen nicht.

View file

@ -22,6 +22,12 @@ return [
], ],
// Gemeinsamer Schluessel fuer den Rueckkanal vom Bot (bot_api.php): im Bot als // Gemeinsamer Schluessel fuer den Rueckkanal vom Bot (bot_api.php): im Bot als
// WEBSITE_BOT_KEY in der .env eintragen. Mindestens 16 Zeichen, z.B. zufaellig erzeugt. // WEBSITE_BOT_KEY in der .env eintragen. Mindestens 16 Zeichen, z.B. zufaellig erzeugt.
// Siel, der Bot der Elyos Allianz: postet deren Raids und kennt Kanaele/Rollen ihres Servers. Der Schluessel
// steht in /root/sielbot/.env (WEBSITE_API_KEY). Ohne diesen Block macht Nezekan (raids_api) alles wie frueher.
'siel_api' => [
'url' => 'https://bot.lumina-ascendens.de/website-api/raids',
'key' => 'schluessel-aus-siel',
],
'bot_callback' => [ 'bot_callback' => [
'key' => 'langer-zufaelliger-schluessel', 'key' => 'langer-zufaelliger-schluessel',
], ],

View file

@ -106,6 +106,18 @@ function discord_bot_post_panel(string $kind, int $channelId, array $roles = [])
function discord_bot_resync_raids(): array function discord_bot_resync_raids(): array
{ {
$data = discord_bot_request('POST', '/raids/resync'); $data = discord_bot_request('POST', '/raids/resync');
// Die Raids der Elyos Allianz gleicht Siel ab
if (siel_api_config() !== null) {
try {
$siel = raids_api_request('POST', '/resync', [], null, 30, 'siel');
$data['updated'] = (int) ($data['updated'] ?? 0) + (int) ($siel['updated'] ?? 0);
$data['reposted'] = array_merge((array) ($data['reposted'] ?? []), (array) ($siel['reposted'] ?? []));
$data['failed'] = array_merge((array) ($data['failed'] ?? []), (array) ($siel['failed'] ?? []));
} catch (Throwable $e) {
$data['failed'] = array_merge((array) ($data['failed'] ?? []),
[['title' => 'Raids der ' . CONSILIUM_NAME, 'error' => $e->getMessage()]]);
}
}
foreach ((array) ($data['reposted'] ?? []) as $moved) { foreach ((array) ($data['reposted'] ?? []) as $moved) {
raid_rename_id((int) ($moved['old'] ?? 0), (int) ($moved['new'] ?? 0)); raid_rename_id((int) ($moved['old'] ?? 0), (int) ($moved['new'] ?? 0));
} }

View file

@ -40,9 +40,14 @@ function events_api_request(string $method, string $path = '', array $queryParam
*/ */
function guilds_api_request(string $path, ?string $guildId = null): array function guilds_api_request(string $path, ?string $guildId = null): array
{ {
$base = preg_replace('#/raids$#', '', raids_api_config()['url']); // $guildId: ein anderer Server als der der Legion (der der Elyos Allianz) - den kennt Siel, falls eingerichtet
$siel = siel_api_config();
if ($guildId !== null && $guildId !== (string) events_guild_id() && $siel !== null) {
$base = preg_replace('#/raids$#', '', $siel['url']);
return bot_api_request('GET', $base . '/guilds/' . $guildId . $path, [], null, 'Siel', $siel['key']);
}
// $guildId: ein anderer Server als der der Legion (der des Consilium Elyseum) $base = preg_replace('#/raids$#', '', raids_api_config()['url']);
return bot_api_request('GET', $base . '/guilds/' . ($guildId ?? events_guild_id()) . $path, [], null, 'Bot-API'); return bot_api_request('GET', $base . '/guilds/' . ($guildId ?? events_guild_id()) . $path, [], null, 'Bot-API');
} }
@ -56,7 +61,7 @@ function guilds_api_request(string $path, ?string $guildId = null): array
* @return array<string, mixed> * @return array<string, mixed>
* @throws RuntimeException * @throws RuntimeException
*/ */
function bot_api_request(string $method, string $url, array $queryParams, ?array $jsonBody, string $label): array function bot_api_request(string $method, string $url, array $queryParams, ?array $jsonBody, string $label, ?string $apiKey = null): array
{ {
if (!function_exists('curl_init')) { if (!function_exists('curl_init')) {
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.'); throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
@ -66,7 +71,7 @@ function bot_api_request(string $method, string $url, array $queryParams, ?array
$url .= '?' . http_build_query($queryParams); $url .= '?' . http_build_query($queryParams);
} }
$headers = ['X-API-Key: ' . raids_api_config()['key']]; $headers = ['X-API-Key: ' . ($apiKey ?? raids_api_config()['key'])];
$ch = curl_init($url); $ch = curl_init($url);
$options = [ $options = [

View file

@ -18,6 +18,38 @@ function bot_api_error_message(string $label, int $httpCode, $data): string
return $detail !== '' ? $message . ' (' . $detail . ')' : $message; return $detail !== '' ? $message . ' (' . $detail . ')' : $message;
} }
/** Abgelehnte Anfrage an einen Bot - mit dem HTTP-Status (404 = dieser Bot kennt den Raid nicht). */
class BotApiException extends RuntimeException
{
public int $httpCode;
public function __construct(string $message, int $httpCode)
{
parent::__construct($message);
$this->httpCode = $httpCode;
}
}
/**
* Siel, der Bot der Elyos Allianz (config.php: siel_api.url = https://bot.lumina-ascendens.de/website-api/raids,
* siel_api.key). Er postet die Raids der Elyos Allianz auf deren Discord-Server und kennt dessen Kanaele und Rollen.
* null = nicht eingerichtet - dann macht Nezekan (raids_api) weiter alles.
*
* @return array{url: string, key: string}|null
*/
function siel_api_config(): ?array
{
static $cfg = false;
if ($cfg === false) {
$configPath = __DIR__ . '/../config.php';
$config = file_exists($configPath) ? require $configPath : [];
$url = is_array($config) ? (string) ($config['siel_api']['url'] ?? '') : '';
$key = is_array($config) ? (string) ($config['siel_api']['key'] ?? '') : '';
$cfg = $url !== '' && $key !== '' ? ['url' => rtrim($url, '/'), 'key' => $key] : null;
}
return $cfg;
}
/** /**
* @return array<string, mixed> * @return array<string, mixed>
* @throws RuntimeException * @throws RuntimeException
@ -52,13 +84,18 @@ function raids_api_config(): array
* @return array<string, mixed> * @return array<string, mixed>
* @throws RuntimeException * @throws RuntimeException
*/ */
function raids_api_request(string $method, string $path = '', array $queryParams = [], ?array $jsonBody = null, int $timeout = 10): array function raids_api_request(string $method, string $path = '', array $queryParams = [], ?array $jsonBody = null, int $timeout = 10, string $backend = 'nezekan'): array
{ {
if (!function_exists('curl_init')) { if (!function_exists('curl_init')) {
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.'); throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
} }
$config = raids_api_config(); // 'siel': der Bot der Elyos Allianz, sonst Nezekan (Legion)
$config = $backend === 'siel' ? siel_api_config() : raids_api_config();
if ($config === null) {
throw new RuntimeException('Siel ist nicht eingerichtet (config.php: siel_api.url / siel_api.key fehlt).');
}
$label = $backend === 'siel' ? 'Siel' : 'Raid-API';
$url = $config['url'] . $path; $url = $config['url'] . $path;
if (!empty($queryParams)) { if (!empty($queryParams)) {
$url .= '?' . http_build_query($queryParams); $url .= '?' . http_build_query($queryParams);
@ -88,22 +125,102 @@ function raids_api_request(string $method, string $path = '', array $queryParams
curl_close($ch); curl_close($ch);
if ($response === false) { if ($response === false) {
throw new RuntimeException('Verbindung zur Raid-API fehlgeschlagen: ' . $curlError); throw new RuntimeException('Verbindung zu ' . $label . ' fehlgeschlagen: ' . $curlError);
} }
$data = json_decode($response, true); $data = json_decode($response, true);
if ($httpCode < 200 || $httpCode >= 300) { if ($httpCode < 200 || $httpCode >= 300) {
throw new RuntimeException(bot_api_error_message('Raid-API', $httpCode, $data)); throw new BotApiException(bot_api_error_message($label, $httpCode, $data), $httpCode);
} }
if (!is_array($data)) { if (!is_array($data)) {
throw new RuntimeException('Unerwartetes Antwortformat der Raid-API.'); throw new RuntimeException('Unerwartetes Antwortformat von ' . $label . '.');
} }
return $data; return $data;
} }
/**
* Raids beider Bots: Nezekan (Legion, aeltere Raids der Elyos Allianz) und Siel (Raids der Elyos Allianz). Jeder Raid
* bekommt "bot" ('nezekan' oder 'siel'). Ist Siel nicht erreichbar, fehlen nur dessen Raids (siel_raids_error()).
*
* @return array<int, array<string, mixed>>
* @throws RuntimeException wenn Nezekan nicht antwortet
*/
function raids_fetch_combined(string $status, int $timeout = 10): array
{
$data = raids_api_request('GET', '', ['status' => $status], null, $timeout);
if (($data['status'] ?? '') !== 'success' || !isset($data['raids']) || !is_array($data['raids'])) {
throw new RuntimeException('Unerwartetes Antwortformat der Raid-API.');
}
$raids = array_map(static fn (array $raid): array => $raid + ['bot' => 'nezekan'], $data['raids']);
if (siel_api_config() !== null) {
try {
$siel = raids_api_request('GET', '', ['status' => $status], null, $timeout, 'siel');
foreach ((array) ($siel['raids'] ?? []) as $raid) {
if (is_array($raid)) {
$raid['bot'] = 'siel';
raid_backend_remember((int) ($raid['raid_id'] ?? 0), 'siel');
$raids[] = $raid;
}
}
siel_raids_error('');
} catch (Throwable $e) {
siel_raids_error($e->getMessage());
}
usort($raids, static fn (array $a, array $b): int => (int) ($a['timestamp'] ?? 0) <=> (int) ($b['timestamp'] ?? 0));
}
return $raids;
}
/** Letzter Fehler beim Abruf der Raids von Siel ('' = alles gut) - lesen ohne, setzen mit Argument. */
function siel_raids_error(?string $set = null): string
{
static $error = '';
if ($set !== null) {
$error = $set;
}
return $error;
}
/** Merkt sich, welcher Bot einen Raid postet (fuer Anfragen per raid_id). Ohne Bot: lesen ('' = unbekannt). */
function raid_backend_remember(int $raidId, ?string $backend = null): string
{
static $known = [];
if ($backend !== null && $raidId > 0) {
$known[$raidId] = $backend;
}
return $known[$raidId] ?? '';
}
/**
* Anfrage zu einem bestimmten Raid - an den Bot, der ihn gepostet hat. Ist er unbekannt, zuerst Nezekan; kennt der
* gefragte Bot den Raid nicht (404), der andere.
*
* @return array<string, mixed>
* @throws RuntimeException
*/
function raid_backend_request(int $raidId, string $method, string $path, ?array $jsonBody = null): array
{
$order = raid_backend_remember($raidId) === 'siel' ? ['siel', 'nezekan'] : ['nezekan', 'siel'];
if (siel_api_config() === null) {
$order = ['nezekan'];
}
foreach ($order as $i => $backend) {
try {
$data = raids_api_request($method, $path, [], $jsonBody, 10, $backend);
raid_backend_remember($raidId, $backend);
return $data;
} catch (BotApiException $e) {
if ($e->httpCode !== 404 || $i === count($order) - 1) {
throw $e;
}
}
}
throw new RuntimeException('Raid nicht gefunden.');
}
// Laengengrenzen der Raid-API (RaidCreate/RaidUpdate in api.py des Bots). // Laengengrenzen der Raid-API (RaidCreate/RaidUpdate in api.py des Bots).
const RAID_FIELD_LIMITS = [ const RAID_FIELD_LIMITS = [
'title' => ['Titel', 60], 'title' => ['Titel', 60],
@ -138,18 +255,14 @@ function fetch_raids(string $status = 'active'): array
$status = 'active'; $status = 'active';
} }
$data = raids_api_request('GET', '', ['status' => $status]); $raids = raids_fetch_combined($status);
if (($data['status'] ?? '') !== 'success' || !isset($data['raids']) || !is_array($data['raids'])) {
throw new RuntimeException('Unerwartetes Antwortformat der Raid-API.');
}
// Die aktiven Raids stecken auch in "all" - so bleibt die Zahl in der Seitenleiste nebenbei aktuell // Die aktiven Raids stecken auch in "all" - so bleibt die Zahl in der Seitenleiste nebenbei aktuell
if ($status !== 'archived') { if ($status !== 'archived') {
raids_nav_store($data['raids']); raids_nav_store($raids);
} }
return raids_apply_display_names($data['raids']); return raids_apply_display_names($raids);
} }
// ---- Zwei Raid-Bereiche: Legion und Consilium Elyseum ---- // ---- Zwei Raid-Bereiche: Legion und Consilium Elyseum ----
@ -164,9 +277,12 @@ function consilium_raid_channel(): int
return (int) setting_get('consilium_raid_channel'); return (int) setting_get('consilium_raid_channel');
} }
/** 'consilium' fuer Raids im Kanal der Consilium-Raids, sonst 'legion'. */ /** 'consilium' fuer Raids von Siel und aeltere im Kanal der Consilium-Raids, sonst 'legion'. */
function raid_area(array $raid): string function raid_area(array $raid): string
{ {
if (($raid['bot'] ?? '') === 'siel') {
return 'consilium';
}
$channel = consilium_raid_channel(); $channel = consilium_raid_channel();
return $channel > 0 && (int) ($raid['channel_id'] ?? 0) === $channel ? 'consilium' : 'legion'; return $channel > 0 && (int) ($raid['channel_id'] ?? 0) === $channel ? 'consilium' : 'legion';
} }
@ -303,10 +419,7 @@ function raids_nav_upcoming(?string $area = null): array
raids_nav_cache(['fetched_at' => time(), 'raids' => $list, 'sig' => (string) ($cached['sig'] ?? ''), raids_nav_cache(['fetched_at' => time(), 'raids' => $list, 'sig' => (string) ($cached['sig'] ?? ''),
'consilium' => (array) ($cached['consilium'] ?? [])]); 'consilium' => (array) ($cached['consilium'] ?? [])]);
try { try {
$data = raids_api_request('GET', '', ['status' => 'active'], null, 3); $list = raids_nav_store(raids_fetch_combined('active', 3));
if (($data['status'] ?? '') === 'success' && is_array($data['raids'] ?? null)) {
$list = raids_nav_store($data['raids']);
}
} catch (Throwable $e) { } catch (Throwable $e) {
// Bot nicht erreichbar oder nicht eingerichtet - dann eben der letzte Stand // Bot nicht erreichbar oder nicht eingerichtet - dann eben der letzte Stand
} }
@ -408,7 +521,7 @@ function raids_apply_display_names(array $raids): array
/** @throws RuntimeException */ /** @throws RuntimeException */
function archive_raid(int $raidId): void function archive_raid(int $raidId): void
{ {
raids_api_request('DELETE', '/' . $raidId); raid_backend_request($raidId, 'DELETE', '/' . $raidId);
} }
/** /**
@ -420,7 +533,7 @@ function archive_raid(int $raidId): void
*/ */
function restore_raid(int $raidId): int function restore_raid(int $raidId): int
{ {
$data = raids_api_request('POST', '/' . $raidId . '/restore'); $data = raid_backend_request($raidId, 'POST', '/' . $raidId . '/restore');
return (int) ($data['raid_id'] ?? $raidId) ?: $raidId; return (int) ($data['raid_id'] ?? $raidId) ?: $raidId;
} }
@ -432,7 +545,7 @@ function restore_raid(int $raidId): int
*/ */
function delete_raid_permanently(int $raidId): void function delete_raid_permanently(int $raidId): void
{ {
raids_api_request('DELETE', '/' . $raidId . '/permanent'); raid_backend_request($raidId, 'DELETE', '/' . $raidId . '/permanent');
} }
/** /**
@ -447,7 +560,7 @@ function delete_raid_permanently(int $raidId): void
*/ */
function raid_signup(int $raidId, int $discordId, string $discordName, string $className, ?int $wish = null): array function raid_signup(int $raidId, int $discordId, string $discordName, string $className, ?int $wish = null): array
{ {
$data = raids_api_request('POST', '/' . $raidId . '/signup', [], [ $data = raid_backend_request($raidId, 'POST', '/' . $raidId . '/signup', [
'user_id' => $discordId, 'user_id' => $discordId,
'name' => $discordName, 'name' => $discordName,
'class' => $className, 'class' => $className,
@ -468,13 +581,13 @@ function raid_signup(int $raidId, int $discordId, string $discordName, string $c
*/ */
function raid_decline(int $raidId, int $discordId, string $name): void function raid_decline(int $raidId, int $discordId, string $name): void
{ {
raids_api_request('POST', '/' . $raidId . '/signup/' . $discordId . '/decline', [], ['name' => $name]); raid_backend_request($raidId, 'POST', '/' . $raidId . '/signup/' . $discordId . '/decline', ['name' => $name]);
} }
/** @throws RuntimeException */ /** @throws RuntimeException */
function move_signup(int $raidId, int $discordId, int $group): void function move_signup(int $raidId, int $discordId, int $group): void
{ {
raids_api_request('PATCH', '/' . $raidId . '/signup/' . $discordId, [], ['group' => $group]); raid_backend_request($raidId, 'PATCH', '/' . $raidId . '/signup/' . $discordId, ['group' => $group]);
} }
/** /**
@ -488,12 +601,13 @@ function move_signup(int $raidId, int $discordId, int $group): void
*/ */
function update_raid(int $raidId, array $fields): array function update_raid(int $raidId, array $fields): array
{ {
return raids_api_request('PATCH', '/' . $raidId, [], $fields); return raid_backend_request($raidId, 'PATCH', '/' . $raidId, $fields);
} }
/** /**
* Erstellt einen neuen Raid ueber den in config.php (raids_api.guild_id) hinterlegten * Erstellt einen neuen Raid ueber den in config.php (raids_api.guild_id) hinterlegten
* Discord-Server. Der Bot postet ihn in den Raid-Kanal dieses Servers (Verwaltung -> Discord-Bot). * Discord-Server. Der Bot postet ihn in den Raid-Kanal dieses Servers (Verwaltung -> Discord-Bot).
* Raids der Elyos Allianz postet Siel (siel_api_config()), sonst - wie frueher - Nezekan.
* *
* @param array<string, mixed> $fields title, date_raw, requirements, group_names * @param array<string, mixed> $fields title, date_raw, requirements, group_names
* (Pflicht), max_slots, gearscore, lead_id, lead_name, points_text (optional) * (Pflicht), max_slots, gearscore, lead_id, lead_name, points_text (optional)
@ -522,7 +636,11 @@ function create_raid(array $fields, string $area = 'legion'): array
$fields['guild_id'] = (int) $guildId; $fields['guild_id'] = (int) $guildId;
return raids_api_request('POST', '', [], $fields); // Raids der Elyos Allianz postet Siel (auf deren Server), sobald er eingerichtet ist
$backend = $area === 'consilium' && siel_api_config() !== null ? 'siel' : 'nezekan';
$data = raids_api_request('POST', '', [], $fields, 10, $backend);
raid_backend_remember((int) ($data['raid_id'] ?? 0), $backend);
return $data;
} }
/** @throws RuntimeException */ /** @throws RuntimeException */

View file

@ -52,6 +52,9 @@ if ($area === 'consilium') {
} }
// Feste Premades, die direkt einer Gruppe zugeordnet werden (Gruppe => Premade-ID). // Feste Premades, die direkt einer Gruppe zugeordnet werden (Gruppe => Premade-ID).
if ($area === 'consilium' && !empty($input['premades'])) {
json_response(false, 'Premades gibt es nur bei Raids der Legion.');
}
$premadeChoices = []; $premadeChoices = [];
foreach ((array) ($input['premades'] ?? []) as $choice) { foreach ((array) ($input['premades'] ?? []) as $choice) {
$group = (int) ($choice['group'] ?? 0); $group = (int) ($choice['group'] ?? 0);

View file

@ -14,6 +14,9 @@ $group = (int) ($input['group'] ?? 0);
if ($raidId <= 0 || $premadeId <= 0 || $group <= 0) { if ($raidId <= 0 || $premadeId <= 0 || $group <= 0) {
json_response(false, 'Bitte Premade und Zielgruppe auswählen.'); json_response(false, 'Bitte Premade und Zielgruppe auswählen.');
} }
if (raid_area_of($raidId) === 'consilium') {
json_response(false, 'Premades gibt es nur bei Raids der Legion.');
}
// Die Leitung in jeden Raid, der Raid-Lead in seinen eigenen // Die Leitung in jeden Raid, der Raid-Lead in seinen eigenen
if (!raid_can_manage($raidId)) { if (!raid_can_manage($raidId)) {
http_response_code(403); http_response_code(403);

View file

@ -75,7 +75,8 @@ if ($apiError === null && $status !== 'archived' && raid_sync_extras($raids, $ra
// Premades fuer das Anlegen und fuers Einladen in eigene (Raid-Lead) bzw. alle Raids (Leitung) // Premades fuer das Anlegen und fuers Einladen in eigene (Raid-Lead) bzw. alle Raids (Leitung)
$premades = []; $premades = [];
if ($canCreateRaids) { // Premades gibt es nur in der Legion - nicht bei den Raids der Elyos Allianz
if ($canCreateRaids && $area !== 'consilium') {
try { try {
$premades = fetch_premades(); $premades = fetch_premades();
} catch (Throwable $e) { } catch (Throwable $e) {