improved user recognition, commands handler fix

This commit is contained in:
t1amak
2025-05-30 21:21:35 +00:00
parent 02dce3692e
commit cc8fbe2487
3 changed files with 105 additions and 73 deletions

View File

@@ -21,8 +21,21 @@ $update = json_decode(file_get_contents("php://input"), true);
if (!$update || !isset($update['message'])) exit;
$message = $update['message'];
$args = explode(' ', trim($message['text'] ?? ''));
$command = strtolower($args[0] ?? '');
//$args = explode(' ', trim($message['text'] ?? ''));
//$command = strtolower($args[0] ?? '');
$text = trim($message['text'] ?? '');
if (!str_starts_with($text, '/')) exit; // Only react to messages that start with '/'
$args = explode(' ', $text);
$command = strtolower($args[0]);
// Strip optional @BotUsername (Telegram adds this in groups)
if (str_contains($command, '@')) {
$command = explode('@', $command)[0];
}
$context = [
'chat_id' => $message['chat']['id'],