← All source files

V9 / fa079a940f8f

SeleniumCommands.cs

Lilith/Core/WebResearch/SeleniumCommands.cs

Unchanged from the preceding version
CS
using Lilith.Core.Commands;

namespace Lilith.Core.WebResearch;

public static class SeleniumCommands
{
    public static void Register(ChatCommandRegistry commands, ProviderClient client) =>
        commands.Register("selenium", "Show Selenium status; headless on/off/toggle controls browser visibility.", context => Execute(client, context.Arguments));

    public static string Execute(ProviderClient client, string arguments)
    {
        string value = string.Join(" ", arguments.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries)).ToLowerInvariant();
        bool headless;
        switch (value)
        {
            case "": case "headless": headless = client.SeleniumHeadless; break;
            case "headless on": headless = client.SetSeleniumHeadless(true); break;
            case "headless off": headless = client.SetSeleniumHeadless(false); break;
            case "headless toggle": headless = client.SetSeleniumHeadless(null); break;
            default: return "Use /selenium, /selenium headless on, /selenium headless off or /selenium headless toggle.";
        }
        return "Selenium headless " + (headless ? "on (browser hidden)." : "off (browser visible).") + " Applies to subsequent browser sessions.";
    }
}