filter plugin by names

This commit is contained in:
Jicheng Lu 2024-11-05 13:14:43 -06:00
parent f032dfc102
commit cdfd622930
2 changed files with 7 additions and 0 deletions

View file

@ -3,5 +3,6 @@ namespace BotSharp.Abstraction.Plugins.Models
public class PluginFilter
{
public Pagination Pager { get; set; } = new Pagination();
public IEnumerable<string>? Names { get; set; }
}
}

View file

@ -126,6 +126,12 @@ public class PluginLoader
var plugins = GetPlugins(services);
var pager = filter?.Pager ?? new Pagination();
// Apply filter
if (!filter.Names.IsNullOrEmpty())
{
plugins = plugins.Where(x => filter.Names.Any(n => x.Name.IsEqualTo(n))).ToList();
}
return new PagedItems<PluginDef>
{
Items = plugins.Skip(pager.Offset).Take(pager.Size),