<?php

declare(strict_types=1);

namespace XBotControl;

use Psr\Http\Message\ServerRequestInterface;
use Clue\React\SQLite\DatabaseInterface;
use Clue\React\SQLite\Result;
use React\Promise\PromiseInterface;

class Bot
{
    
    // Helper Functions
    public function isBot($userAgent): bool
    {
        $botKeywords = ['bot', 'crawl', 'spider', 'slurp', 'archive'];
        foreach ($botKeywords as $keyword) {
            if (stripos($userAgent, $keyword) !== false) {
                return true;
            }
        }
        return false;
    }

    public function extractBotName($userAgent): string|null
    {
        preg_match('/bot|crawl|spider|slurp|archive/i', $userAgent, $matches);
        return $matches[0] ?? null;
    }}