Пример #1
0
        public MovingWorker(ILogger <MovingWorker> logger,
                            IOptionsMonitor <AppOptions> appOptionsAccessor,
                            IOptionsMonitor <DiscordOptions> discordOptionsAccessor,
                            IDiscordConnectionStorage discordConnectionStorage,
                            HubConnection hub,
                            ChannelMaker channelMaker)
        {
            this.logger                   = logger;
            this.appOptions               = appOptionsAccessor.CurrentValue;
            this.discordOptions           = discordOptionsAccessor.CurrentValue;
            this.discordConnectionStorage = discordConnectionStorage;
            this.hub          = hub;
            this.channelMaker = channelMaker;
            hub.Reconnecting += Hub_Reconnecting;
            hub.Reconnected  += Hub_Reconnected;
            hub.Closed       += Hub_Closed;

            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);
                }
            });
        }
Пример #2
0
 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;
 }