Exemple #1
0
        public MovingWorker(ILogger <MovingWorker> logger,
                            IOptionsMonitor <AppOptions> appOptionsAccessor,
                            IOptionsMonitor <DiscordOptions> discordOptionsAccessor,
                            IDiscordConnectionStorage discordConnectionStorage,
                            HubConnection hub)
        {
            this.logger                   = logger;
            this.appOptions               = appOptionsAccessor.CurrentValue;
            this.discordOptions           = discordOptionsAccessor.CurrentValue;
            this.discordConnectionStorage = discordConnectionStorage;
            this.hub = hub;

            hub.Reconnecting += Hub_Reconnecting;
            hub.Reconnected  += Hub_Reconnected;

            hub.On <string, int?, int?>("ChangeFrequency", async(clientId, from, to) =>
            {
                try
                {
                    logger.LogDebug("Got ChangeFrequency message from {clientId} to change from {fromFrequency} to {toFrequency}", clientId, from, to);
                    await CreateVoiceChannelAndMoveAsync(clientId, to);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "Cannot handle changing frequency of {0} from {1} to {2}!", clientId, from, to);
                }
            });
        }
Exemple #2
0
 public CleaningWorker(ILogger <CleaningWorker> logger,
                       IOptionsMonitor <AppOptions> appOptionsAccessor,
                       IOptionsMonitor <DiscordOptions> discordOptionsAccessor)
 {
     this.logger         = logger;
     this.appOptions     = appOptionsAccessor.CurrentValue;
     this.discordOptions = discordOptionsAccessor.CurrentValue;
 }
 public AtisWorker(ILogger <AtisWorker> logger,
                   IOptionsMonitor <AtisOptions> atisOptions,
                   IOptionsMonitor <DiscordOptions> discordOptions,
                   ChannelMaker channelMaker,
                   RegexMatcher regexMatcher,
                   AtisProcessManager atisProcessManager)
 {
     this.logger             = logger;
     this.channelMaker       = channelMaker;
     this.regexMatcher       = regexMatcher;
     this.atisProcessManager = atisProcessManager;
     this.atisOptions        = atisOptions.CurrentValue;
     this.discordOptions     = discordOptions.CurrentValue;
 }
        public DiscordMessageWorker(
            ILoggerFactory loggerFactory,
            ILogger <DiscordMessageWorker> logger,
            IOptionsMonitor <DiscordOptions> discordOptionsAccessor,
            HubConnection hub)
        {
            this.logger         = logger;
            this.discordOptions = discordOptionsAccessor.CurrentValue;

            botClient = new DiscordSocketClient();

            messageHandlers = new List <IMessageHandler>
            {
                new RateChangeMessageHandler(hub),
                new FlightInfoMessageHandler(loggerFactory.CreateLogger <FlightInfoMessageHandler>(), discordOptionsAccessor, hub)
            };
        }