BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Functions/EvaluateScriptFn.cs

25 lines
639 B
C#
Raw Normal View History

2024-02-02 04:16:57 +00:00
using BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
namespace BotSharp.Plugin.WebDriver.Functions;
public class EvaluateScriptFn : IFunctionCallback
2024-02-02 04:16:57 +00:00
{
public string Name => "evaluate_script";
2024-02-02 04:16:57 +00:00
private readonly IServiceProvider _services;
private readonly PlaywrightWebDriver _driver;
public EvaluateScriptFn(IServiceProvider services,
2024-02-02 04:16:57 +00:00
PlaywrightWebDriver driver)
{
_services = services;
_driver = driver;
}
public async Task<bool> Execute(RoleDialogModel message)
{
message.Data = await _driver.EvaluateScript<object>(message.Content);
2024-02-02 04:16:57 +00:00
return true;
}
}