Bot-Rueckkanal: bot_api.php?action=raid_archived - meldet der Bot einen automatisch archivierten Raid (cogs/raid_autoarchive.py, 2 Stunden nach Beginn), vergibt die Website die Lumipunkte wie beim Archivieren von Hand und schreibt einen Log-Eintrag. Wirkt erst, wenn der Bot das Cog bekommt (liegt bisher nur lokal)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
05d76234ce
commit
892037cdab
1 changed files with 31 additions and 0 deletions
31
bot_api.php
31
bot_api.php
|
|
@ -8,6 +8,11 @@
|
||||||
* alle Angemeldeten mit einem aktiven Website-Konto und der Berechtigung raids.manage. Die PN schickt der Bot.
|
* alle Angemeldeten mit einem aktiven Website-Konto und der Berechtigung raids.manage. Die PN schickt der Bot.
|
||||||
* GET /bot_api.php?action=attendance_recipients&raid_id=...&discord_ids=1,2,3
|
* GET /bot_api.php?action=attendance_recipients&raid_id=...&discord_ids=1,2,3
|
||||||
*
|
*
|
||||||
|
* Raids automatisch archivieren (cogs/raid_autoarchive.py im Bot): 1,5 Stunden nach Raidbeginn erinnert der Bot dieselben
|
||||||
|
* Leute wie bei der Anwesenheit (attendance_recipients), den Raid zu archivieren; 2 Stunden nach Beginn archiviert er
|
||||||
|
* ihn selbst und meldet das hier - die Website vergibt dann die Lumipunkte wie beim Archivieren von Hand.
|
||||||
|
* POST /bot_api.php?action=raid_archived {"raid_id": "..."}
|
||||||
|
*
|
||||||
* Raid-Anmeldung im Discord (cogs/teamplaner.py, website.py im Bot): Main-Klasse eines Spielers (im Profil
|
* Raid-Anmeldung im Discord (cogs/teamplaner.py, website.py im Bot): Main-Klasse eines Spielers (im Profil
|
||||||
* waehlbar) und ob er ein (freigeschaltetes) Konto hat - ohne gibt es keine Lumipunkte.
|
* waehlbar) und ob er ein (freigeschaltetes) Konto hat - ohne gibt es keine Lumipunkte.
|
||||||
* GET /bot_api.php?action=member&discord_id=...
|
* GET /bot_api.php?action=member&discord_id=...
|
||||||
|
|
@ -144,6 +149,32 @@ if ($action === 'consilium_legions') {
|
||||||
bot_api_reply(503, ['status' => 'error', 'message' => 'Die Website ist dafür noch nicht eingerichtet.']);
|
bot_api_reply(503, ['status' => 'error', 'message' => 'Die Website ist dafür noch nicht eingerichtet.']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($action === 'raid_archived') {
|
||||||
|
// Der Bot hat einen Raid 2 Stunden nach Beginn automatisch archiviert (cogs/raid_autoarchive.py) - danach
|
||||||
|
// passiert dasselbe wie beim Archivieren auf der Website (raid_archive.php): Lumipunkte und Log-Eintrag.
|
||||||
|
$body = json_decode((string) file_get_contents('php://input'), true);
|
||||||
|
$raidId = (int) (is_array($body) ? ($body['raid_id'] ?? 0) : 0);
|
||||||
|
if ($raidId <= 0) {
|
||||||
|
bot_api_reply(400, ['status' => 'error', 'message' => 'raid_id fehlt.']);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$raid = fetch_raid_by_id($raidId);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$raid = null;
|
||||||
|
}
|
||||||
|
if ($raid === null || (empty($raid['archived']) && empty($raid['archived_at']))) {
|
||||||
|
bot_api_reply(409, ['status' => 'error', 'message' => 'Der Raid ist nicht archiviert.']);
|
||||||
|
}
|
||||||
|
raid_settings_ensure_defaults([$raidId]); // fester Punkt auch fuer im Discord erstellte Raids
|
||||||
|
$messages = array_values(array_filter(raid_process_auto_points([$raid])));
|
||||||
|
admin_log('📦 Raid automatisch archiviert', [
|
||||||
|
'Raid' => admin_log_raid($raidId),
|
||||||
|
'Grund' => '2 Stunden nach Raidbeginn noch nicht archiviert',
|
||||||
|
'Anmeldungen' => admin_log_raid_signups($raid),
|
||||||
|
'Lumipunkte' => implode("\n", $messages),
|
||||||
|
], 'warning');
|
||||||
|
bot_api_reply(200, ['status' => 'success', 'messages' => $messages]);
|
||||||
|
}
|
||||||
if ($action !== 'attendance_recipients') {
|
if ($action !== 'attendance_recipients') {
|
||||||
bot_api_reply(400, ['status' => 'error', 'message' => 'Unbekannte Aktion.']);
|
bot_api_reply(400, ['status' => 'error', 'message' => 'Unbekannte Aktion.']);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue