Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
 public LersBotService(IHostApplicationLifetime lifeTime,
                       UsersService users,
                       IOptionsSnapshot <Config> config,
                       LersBot bot,
                       Notifier notifier)
 {
     _bot      = bot;
     _lifeTime = lifeTime;
     _users    = users;
     _config   = config.Value;
     _notifier = notifier;
 }
Exemplo n.º 3
0
 public Notifier(LersBot bot)
 {
     this.bot = bot;
     this.notifyThread.DoWork += NotifyThread_DoWork;
 }
Exemplo n.º 4
0
 public Notifier(UsersService users, LersBot bot)
 {
     _bot   = bot;
     _users = users;
 }