public NavViewComponent(
     IStreamStatusApiClient streamStatusClient,
     IModService modService,
     IConfigService configService)
 {
     _streamStatusClient = streamStatusClient;
     _modService         = modService;
     _configService      = configService;
 }
Пример #2
0
        private readonly string _developmentRoomId = string.Empty; // Only for use in debug mode

        public ChatbotService(ICommandHelper commandHelper,
                              ITwitchClientFactory twitchClientFactory,
                              TwitchPubSub pubsub,
                              ITwitchLiveStreamMonitorFactory twitchLiveStreamMonitorFactory,
                              IVipApiClient vipApiClient,
                              IConfigService configService,
                              IStreamStatusApiClient streamStatusApiClient,
                              ISecretService secretService,
                              ILogger <ChatbotService> logger)
        {
            _commandHelper = commandHelper;
            _pubsub        = pubsub;
            _twitchLiveStreamMonitorFactory = twitchLiveStreamMonitorFactory;
            _vipApiClient          = vipApiClient;
            _configService         = configService;
            _streamStatusApiClient = streamStatusApiClient;
            _secretService         = secretService;
            _logger = logger;

            _streamerChannel    = _configService.Get <string>("StreamerChannel");
            _isDevelopmentBuild = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" ||
                                  Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Local";

            _client = twitchClientFactory.Get();

            _client.OnJoinedChannel         += OnJoinedChannel;
            _client.OnChatCommandReceived   += OnCommandReceived;
            _client.OnCommunitySubscription += OnSubBomb;
            _client.OnBeingHosted           += OnBeingHosted;
            _client.OnRaidNotification      += OnRaidNotification;
            _client.OnDisconnected          += OnDisconnected;
            _client.OnError           += OnError;
            _client.OnConnectionError += OnConnectionError;
            _client.Connect();

            _liveStreamMonitor = _twitchLiveStreamMonitorFactory.Get();

            _liveStreamMonitor.SetChannelsByName(new List <string> {
                _streamerChannel
            });
            _liveStreamMonitor.OnStreamOnline   += OnStreamOnline;
            _liveStreamMonitor.OnStreamOffline  += OnStreamOffline;
            _liveStreamMonitor.OnServiceStarted += OnStreamMonitorStarted;
            //this.liveStreamMonitor.OnStreamUpdate += OnStreamUpdate;

            _liveStreamMonitor.Start();

            _pubsub.OnPubSubServiceConnected += OnPubSubConnected;
            _pubsub.OnBitsReceived           += OnBitsReceived;
            _pubsub.OnListenResponse         += OnListenResponse;
            _pubsub.OnChannelSubscription    += OnSub;

            _pubsub.Connect();
        }