V1.1.0
This commit is contained in:
parent
fb07ff7d2e
commit
347a95a312
BIN
assets/pasted-20260409-011806-1d0a77ea.png
Normal file
BIN
assets/pasted-20260409-011806-1d0a77ea.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 342 KiB |
@ -393,30 +393,32 @@ function scdiscord_apply_bot_actions(array $message_data, bool $use_reactions, b
|
||||
}
|
||||
|
||||
$details = [];
|
||||
$failed = false;
|
||||
$last_http_code = 200;
|
||||
$failed = false;
|
||||
|
||||
if ($use_reactions) {
|
||||
foreach (['👍', '⌛', '❔', '👎'] as $emoji) {
|
||||
$url = 'https://discord.com/api/v10/channels/' . rawurlencode($channel_id) . '/messages/' . rawurlencode($message_id) . '/reactions/' . rawurlencode($emoji) . '/@me';
|
||||
$result = scdiscord_bot_request('PUT', $url, $bot_token);
|
||||
$action_success = !empty($result['success']);
|
||||
$last_http_code = (int) ($result['http_code'] ?? $last_http_code);
|
||||
$details[] = [
|
||||
'action' => 'reaction',
|
||||
'emoji' => $emoji,
|
||||
'success' => !empty($result['success']),
|
||||
'http_code' => (int) ($result['http_code'] ?? 0),
|
||||
'success' => $action_success,
|
||||
'http_code' => $last_http_code,
|
||||
'response' => (string) ($result['response'] ?? ''),
|
||||
];
|
||||
$last_http_code = (int) ($result['http_code'] ?? $last_http_code);
|
||||
if (empty($result['success'])) {
|
||||
|
||||
if (!$action_success) {
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
usleep(300000);
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$failed && $use_publicthread) {
|
||||
if ($use_publicthread) {
|
||||
$thread_payload = [
|
||||
'name' => $thread_name !== '' ? $thread_name : 'Discussion - Opération',
|
||||
'auto_archive_duration' => 1440,
|
||||
@ -424,14 +426,16 @@ function scdiscord_apply_bot_actions(array $message_data, bool $use_reactions, b
|
||||
];
|
||||
$url = 'https://discord.com/api/v10/channels/' . rawurlencode($channel_id) . '/messages/' . rawurlencode($message_id) . '/threads';
|
||||
$result = scdiscord_bot_request('POST', $url, $bot_token, $thread_payload);
|
||||
$action_success = !empty($result['success']);
|
||||
$last_http_code = (int) ($result['http_code'] ?? $last_http_code);
|
||||
$details[] = [
|
||||
'action' => 'thread',
|
||||
'success' => !empty($result['success']),
|
||||
'http_code' => (int) ($result['http_code'] ?? 0),
|
||||
'success' => $action_success,
|
||||
'http_code' => $last_http_code,
|
||||
'response' => (string) ($result['response'] ?? ''),
|
||||
];
|
||||
$last_http_code = (int) ($result['http_code'] ?? $last_http_code);
|
||||
if (empty($result['success'])) {
|
||||
|
||||
if (!$action_success) {
|
||||
$failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,20 +32,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$_SESSION['scnotification_old'] = $_POST;
|
||||
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
if ($action === 'send_notification') {
|
||||
$is_legacy_send = $action === '' && (isset($_POST['description']) || isset($_POST['title']) || isset($_POST['webhook_choice']));
|
||||
if ($action === 'send_notification' || $is_legacy_send) {
|
||||
$legacy_webhook_choice = trim((string) ($_POST['webhook_choice'] ?? ''));
|
||||
$cl_scnotification_webhook_id = (int) ($_POST['cl_scnotification_webhook_id'] ?? 0);
|
||||
if ($cl_scnotification_webhook_id <= 0 && preg_match('/^notif(\d+)$/', $legacy_webhook_choice, $matches)) {
|
||||
$cl_scnotification_webhook_id = (int) $matches[1];
|
||||
}
|
||||
|
||||
$cl_scnotification_banner_id = (int) ($_POST['cl_scnotification_banner_id'] ?? 0);
|
||||
$use_custom_banner = isset($_POST['cl_scnotification_use_custom_banner']);
|
||||
$cl_scnotification_custom_banner_url = trim((string) ($_POST['cl_scnotification_custom_banner_url'] ?? ''));
|
||||
$notify_here = isset($_POST['cl_scnotification_notify_here']);
|
||||
$notify_everyone = isset($_POST['cl_scnotification_notify_everyone']);
|
||||
$cl_scnotification_title = trim((string) ($_POST['cl_scnotification_title'] ?? ''));
|
||||
$cl_scnotification_message = trim((string) ($_POST['cl_scnotification_message'] ?? ''));
|
||||
$use_custom_banner = isset($_POST['cl_scnotification_use_custom_banner']) || isset($_POST['use_custom_banner']);
|
||||
$cl_scnotification_custom_banner_url = trim((string) ($_POST['cl_scnotification_custom_banner_url'] ?? ($_POST['custom_banner'] ?? '')));
|
||||
$notify_here = isset($_POST['cl_scnotification_notify_here']) || isset($_POST['ping_here']);
|
||||
$notify_everyone = isset($_POST['cl_scnotification_notify_everyone']) || isset($_POST['ping_everyone']);
|
||||
$cl_scnotification_title = trim((string) ($_POST['cl_scnotification_title'] ?? ($_POST['title'] ?? '')));
|
||||
$cl_scnotification_message = trim((string) ($_POST['cl_scnotification_message'] ?? ($_POST['description'] ?? '')));
|
||||
$show_footer = isset($_POST['cl_scnotification_show_footer']);
|
||||
$cl_scnotification_footer_text = trim((string) ($_POST['cl_scnotification_footer_text'] ?? ''));
|
||||
$cl_scnotification_footer_icon_url = trim((string) ($_POST['cl_scnotification_footer_icon_url'] ?? ''));
|
||||
$show_reactions = isset($_POST['cl_scnotification_show_reactions']);
|
||||
$show_thread = isset($_POST['cl_scnotification_show_thread']);
|
||||
$show_reactions = isset($_POST['cl_scnotification_show_reactions']) || isset($_POST['use_reactions']);
|
||||
$show_thread = isset($_POST['cl_scnotification_show_thread']) || isset($_POST['use_publicthread']);
|
||||
$show_org = isset($_POST['cl_scnotification_show_org']);
|
||||
$cl_scnotification_org_value = trim((string) ($_POST['cl_scnotification_org_value'] ?? ''));
|
||||
$show_pvp = isset($_POST['cl_scnotification_show_pvp']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user