Добавил DI, основные классы создаются через вбрасывание зависимостей через конструктор
This commit is contained in:
+4
-3
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Args;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
using ZaoBot.Config;
|
||||
|
||||
namespace ZaoBot
|
||||
{
|
||||
@@ -20,15 +21,15 @@ namespace ZaoBot
|
||||
|
||||
bool shouldRestart = false;
|
||||
|
||||
public BotService(JsonDocument config)
|
||||
public BotService(IConfig config, OpenHab.OpenHabClient openhab)
|
||||
{
|
||||
this.config = config;
|
||||
this.config = config.Data;
|
||||
this.openhab = openhab;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var token = config.RootElement.GetProperty("token").GetString();
|
||||
openhab = new OpenHab.OpenHabClient(config.RootElement.GetProperty("openhab_url").GetString());
|
||||
while (true)
|
||||
{
|
||||
shouldRestart = false;
|
||||
|
||||
Reference in New Issue
Block a user