/// <summary> /// Вызывается при запуске службы. /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { try { Config.Load(); User.LoadList(); Logger.Initialize(Config.LogFilePath); bot = new LersBot(); notifier = new Notifier(bot); Logger.LogMessage($"Stariting {bot.UserName}"); bot.AddCommandHandler(HandleStart, StartCommand); bot.AddCommandHandler(ShowCurrents, GetCurrentsCommand); bot.AddCommandHandler(ShowNodes, GetNodesCommand); bot.AddCommandHandler(ShowMeasurePoints, GetMeasurePointsCommand); bot.AddCommandHandler(notifier.ProcessSetNotifyOn, SetNotifyOnCommand); bot.AddCommandHandler(notifier.ProcessSetNotifyOff, SetNotifyOffCommand); bot.Start(); notifier.Start(); } catch (Exception exc) { Logger.LogMessage($"Ошибка запуска бота. {exc.ToString()}"); throw; } }
public LersBotService(IHostApplicationLifetime lifeTime, UsersService users, IOptionsSnapshot <Config> config, LersBot bot, Notifier notifier) { _bot = bot; _lifeTime = lifeTime; _users = users; _config = config.Value; _notifier = notifier; }
public Notifier(LersBot bot) { this.bot = bot; this.notifyThread.DoWork += NotifyThread_DoWork; }
public Notifier(UsersService users, LersBot bot) { _bot = bot; _users = users; }