{\rtf1\ansi\ansicpg1252\cocoartf2822 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} {\*\expandedcolortbl;;} \paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 \f0\fs24 \cf0 [], "plantes" => []]));\ \}\ \ $data = json_decode(file_get_contents("data.json"), true);\ \ $input = json_decode(file_get_contents("php://input"), true);\ file_put_contents("debug.txt", json_encode($input, JSON_PRETTY_PRINT));\ $chat_id = $input['message']['chat']['id'] ?? null;\ $text = strtolower(trim($input['message']['text'] ?? ''));\ \ if (!$chat_id) \{\ http_response_code(200);\ exit("Aucun chat_id fourni.");\ \}\ \ $response = "";\ $today = date("Y-m-d");\ \ switch ($text) \{\ case "/start":\ $response = "Bonjour, je suis JeanThibot.\\n\\nCommandes utiles :\\n/rappels\\n/plantes\\n/crypto\\n/stocks\\n/evenements\\n/actu\\n/resume\\n/demain\\n/techniq";\ break;\ \ case "/rappels":\ $tasks_today = array_filter($data['tasks'], fn($t) => $t['date'] === $today && !$t['done']);\ $response = count($tasks_today) ? "\uc0\u55357 \u56541 Rappels du jour :\\n" . implode("\\n", array_map(fn($t) => "- " . $t['title'], $tasks_today)) : "\u9989 Aucun rappel pr\'e9vu pour aujourd'hui.";\ break;\ \ case "/plantes":\ $plants_to_water = [];\ foreach ($data['plantes'] as $plante) \{\ $days = (strtotime($today) - strtotime($plante['dernier_arrosage'])) / 86400;\ if ($days >= $plante['frequence']) \{\ $plants_to_water[] = "- " . $plante['nom'] . " (il y a " . intval($days) . " jours)";\ \}\ \}\ $response = count($plants_to_water) ? "\uc0\u55358 \u57012 \'c0 arroser :\\n" . implode("\\n", $plants_to_water) : "\u9989 Aucune plante \'e0 arroser aujourd'hui.";\ break;\ \ case "/crypto":\ $response = "\uc0\u55357 \u56520 Crypto (simul\'e9) :\\n- Bitcoin : 42 300 $ (-2.3%)\\n- Solana : 94.12 $ (+1.7%)";\ break;\ \ case "/stocks":\ $response = "\uc0\u55357 \u56522 Actions (simul\'e9) :\\n- AAPL : 176.12 $\\n- TSLA : 189.33 $";\ break;\ \ case "/evenements":\ $response = "\uc0\u55356 \u57225 \'c9v\'e9nements \'e0 Montr\'e9al (simul\'e9) :\\n- Fuego Fuego, 25 mai\\n- March\'e9 Jean-Talon, week-end\\n- Exposition Design au Centre PHI";\ break;\ \ case "/actu":\ $response = "\uc0\u55357 \u56560 Actu du jour (simul\'e9) :\\n- FR : R\'e9forme en discussion \'e0 l'Assembl\'e9e\\n- QC : Budget 2025 pr\'e9sent\'e9\\n- CAN : Croissance \'e9conomique stable\\n- USA : Tensions pr\'e9-\'e9lectorales";\ break;\ \ case "/resume":\ $done = array_filter($data['tasks'], fn($t) => $t['date'] === $today && $t['done']);\ $todo = array_filter($data['tasks'], fn($t) => $t['date'] === $today && !$t['done']);\ $response = "\uc0\u55357 \u56523 R\'e9sum\'e9 du jour :\\n";\ $response .= "\uc0\u9989 Termin\'e9 :\\n" . (count($done) ? implode("\\n", array_map(fn($t) => "- " . $t['title'], $done)) : "- Rien termin\'e9") . "\\n";\ $response .= "\uc0\u55357 \u56577 \'c0 faire :\\n" . (count($todo) ? implode("\\n", array_map(fn($t) => "- " . $t['title'], $todo)) : "- Tout est fait");\ break;\ \ case "/demain":\ $tomorrow = date("Y-m-d", strtotime("+1 day"));\ $tom_tasks = array_filter($data['tasks'], fn($t) => $t['date'] === $tomorrow);\ $response = "\uc0\u55357 \u56517 Demain :\\n" . (count($tom_tasks) ? implode("\\n", array_map(fn($t) => "- " . $t['title'], $tom_tasks)) : "- Rien de pr\'e9vu.");\ break;\ \ case "/techniq":\ $response = "\uc0\u55357 \u56521 Analyse technique (\'e0 impl\'e9menter) :\\n- D\'e9tection StochRSI & WaveTrend\\n- Sur les actifs : FEQT, XEQT, S&P500, NASDAQ, AAPL, NVDA, TSLA, MSFT, AMD, ETH, BTC, ETHUSDT, etc.\\n\\n\u9989 Fonction \'e0 venir : notifications en cas de croisement matin, soir, ou temps r\'e9el";\ break;\ \ default:\ $response = "Commande inconnue. Essaie : /rappels, /plantes, /crypto, /stocks, /evenements, /actu, /resume, /demain, /techniq";\ break;\ \}\ \ file_get_contents("https://api.telegram.org/bot$token/sendMessage?chat_id=$chat_id&text=" . urlencode($response));\ \ }