2017-10-13 04:14:54 +00:00
|
|
|
|
using NadekoBot.Core.Services;
|
2017-10-04 22:51:12 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
2017-10-13 04:14:54 +00:00
|
|
|
|
namespace NadekoBot.Modules.Administration.Services
|
2017-10-04 22:51:12 +00:00
|
|
|
|
{
|
|
|
|
|
public class PackagesService : INService
|
|
|
|
|
{
|
|
|
|
|
public IEnumerable<string> Packages { get; private set; }
|
|
|
|
|
|
|
|
|
|
public PackagesService()
|
|
|
|
|
{
|
|
|
|
|
ReloadAvailablePackages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ReloadAvailablePackages()
|
|
|
|
|
{
|
|
|
|
|
Packages = Directory.GetDirectories(Path.Combine(AppContext.BaseDirectory, "modules\\"), "NadekoBot.Modules.*", SearchOption.AllDirectories)
|
|
|
|
|
.SelectMany(x => Directory.GetFiles(x, "NadekoBot.Modules.*.dll"))
|
|
|
|
|
.Select(x => Path.GetFileNameWithoutExtension(x))
|
|
|
|
|
.Select(x =>
|
|
|
|
|
{
|
|
|
|
|
var m = Regex.Match(x, @"NadekoBot\.Modules\.(?<name>.*)");
|
|
|
|
|
return m.Groups["name"].Value;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|