コード例 #1
0
        private async Task ApplyBotConfigurationAsync(DiscordSettings discordSettings)
        {
            try
            {
                await _client.UpdateStatusAsync(new DiscordActivity(discordSettings.StatusMessage, ActivityType.Playing));
            }
            catch (System.Exception ex)
            {
                _logger.LogError(ex, "Error update the bot's status: " + ex.Message);
            }

            try
            {
                if (_movieNotificationEngine != null)
                {
                    await _movieNotificationEngine.StopAsync();
                }

                if (_currentSettings.MovieDownloadClient != DownloadClient.Disabled && _currentSettings.NotificationMode != NotificationMode.Disabled)
                {
                    _movieNotificationEngine = _movieWorkflowFactory.CreateMovieNotificationEngine(_client, _logger);
                }

                _movieNotificationEngine?.Start();
            }
            catch (System.Exception ex)
            {
                _logger.LogError(ex, "Error while starting movie notification engine: " + ex.Message);
            }

            try
            {
                if (_tvShowNotificationEngine != null)
                {
                    await _tvShowNotificationEngine.StopAsync();
                }

                if (_currentSettings.TvShowDownloadClient != DownloadClient.Disabled && _currentSettings.NotificationMode != NotificationMode.Disabled)
                {
                    _tvShowNotificationEngine = _tvShowWorkflowFactory.CreateTvShowNotificationEngine(_client, _logger);
                }

                _tvShowNotificationEngine?.Start();
            }
            catch (System.Exception ex)
            {
                _logger.LogError(ex, "Error while starting tv show notification engine: " + ex.Message);
            }
        }
コード例 #2
0
        private async Task Connected()
        {
            try
            {
                if (_movieNotificationEngine != null)
                {
                    await _movieNotificationEngine.StopAsync();
                }

                if (_currentSettings.MovieDownloadClient != DownloadClient.Disabled)
                {
                    _movieNotificationEngine = new MovieNotificationEngine(GetMovieClient <IMovieSearcher>(_currentSettings), new UserMovieNotifier(_client), _logger, _movieNotificationRequestRepository);
                    _movieNotificationEngine.Start();
                }
            }
            catch (System.Exception ex)
            {
                _logger.LogWarning("Error while starting movie notification engine: " + ex.Message);
            }

            try
            {
                if (_tvShowNotificationEngine != null)
                {
                    await _tvShowNotificationEngine.StopAsync();
                }

                if (_currentSettings.TvShowDownloadClient != DownloadClient.Disabled)
                {
                    _tvShowNotificationEngine = new TvShowNotificationEngine(GetTvShowClient <ITvShowSearcher>(_currentSettings), new UserTvShowNotifier(_client), _logger, _tvShowNotificationRequestRepository);
                    _tvShowNotificationEngine.Start();
                }
            }
            catch (System.Exception ex)
            {
                _logger.LogWarning("Error while starting tv show notification engine: " + ex.Message);
            }
        }
コード例 #3
0
ファイル: ChatBot.cs プロジェクト: hthighwaymonk/requestrr
        private async Task Connected()
        {
            try
            {
                if (_movieNotificationEngine != null)
                {
                    await _movieNotificationEngine.StopAsync();
                }

                if (_currentSettings.MovieDownloadClient != DownloadClient.Disabled && _currentSettings.NotificationMode != NotificationMode.Disabled)
                {
                    IMovieNotifier movieNotifier = null;

                    if (_currentSettings.NotificationMode == NotificationMode.PrivateMessage)
                    {
                        movieNotifier = new PrivateMessageMovieNotifier(_client, _logger);
                    }
                    else if (_currentSettings.NotificationMode == NotificationMode.Channels)
                    {
                        movieNotifier = new ChannelMovieNotifier(_client, _currentSettings.NotificationChannels, _logger);
                    }
                    else
                    {
                        throw new Exception($"Could not create movie notifier of type \"{_currentSettings.NotificationMode}\"");
                    }

                    _movieNotificationEngine = new MovieNotificationEngine(GetMovieClient <IMovieSearcher>(_currentSettings), movieNotifier, _logger, _movieNotificationRequestRepository);
                    _movieNotificationEngine.Start();
                }
            }
            catch (System.Exception ex)
            {
                _logger.LogError(ex, "Error while starting movie notification engine: " + ex.Message);
            }

            try
            {
                if (_tvShowNotificationEngine != null)
                {
                    await _tvShowNotificationEngine.StopAsync();
                }

                if (_currentSettings.TvShowDownloadClient != DownloadClient.Disabled && _currentSettings.NotificationMode != NotificationMode.Disabled)
                {
                    ITvShowNotifier tvShowNotifier = null;

                    if (_currentSettings.NotificationMode == NotificationMode.PrivateMessage)
                    {
                        tvShowNotifier = new PrivateMessageTvShowNotifier(_client, _logger);
                    }
                    else if (_currentSettings.NotificationMode == NotificationMode.Channels)
                    {
                        tvShowNotifier = new ChannelTvShowNotifier(_client, _currentSettings.NotificationChannels, _logger);
                    }
                    else
                    {
                        throw new Exception($"Could not create tv show notifier of type \"{_currentSettings.NotificationMode}\"");
                    }

                    _tvShowNotificationEngine = new TvShowNotificationEngine(GetTvShowClient <ITvShowSearcher>(_currentSettings), tvShowNotifier, _logger, _tvShowNotificationRequestRepository);
                    _tvShowNotificationEngine.Start();
                }
            }
            catch (System.Exception ex)
            {
                _logger.LogError(ex, "Error while starting tv show notification engine: " + ex.Message);
            }
        }