mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
🚧 Core improvements
This commit is contained in:
+10
-2
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Kruzya.TelegramBot.Core
|
||||
{
|
||||
@@ -47,7 +48,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
// And register in internal temporary array.
|
||||
var modulesDirectory = new List<string>(new string[]
|
||||
{
|
||||
Path.Join(Assembly.GetExecutingAssembly().Location, "modules"),
|
||||
Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "modules"),
|
||||
Path.Join(Environment.CurrentDirectory, "modules")
|
||||
});
|
||||
|
||||
@@ -58,7 +59,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
return modulesDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public Core(IConfiguration configuration)
|
||||
@@ -92,6 +93,12 @@ namespace Kruzya.TelegramBot.Core
|
||||
types.AddRange(assemblyTypes);
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiate them.
|
||||
foreach (var module in types)
|
||||
{
|
||||
EnsureLoaded(module);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -143,6 +150,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
if (module == null)
|
||||
{
|
||||
module = (Module) Activator.CreateInstance(moduleType, this);
|
||||
Console.WriteLine($"Started module {module.GetType().FullName}");
|
||||
_modules.Add(module);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user