示例#1
0
 public OBSServices(
     OBSWebsocket obs,
     IOptions <OBSConfig> obsConfig,
     INotifierMediatorService notifierMediatorService,
     ILogger <OBSServices> logger)
 {
     OBSClient  = obs;
     _obsConfig = obsConfig.Value;
     _notifierMediatorService = notifierMediatorService;
     _logger = logger;
     SetupOBS();
 }
示例#2
0
 public OBSServices(
     IServiceProvider services,
     IOptions <OBSConfig> obsConfig,
     INotifierMediatorService notifierMediatorService,
     ILoggerFactory loggerFactory
     )
 {
     _obsConfig = obsConfig.Value;
     _services  = services;
     _notifierMediatorService = notifierMediatorService;
     _logger = loggerFactory.CreateLogger <OBSServices>();
     SetupOBS();
 }
示例#3
0
        public TwitchBot(
            IOptions <TwitchConfig> config,
            IOptions <OBSConfig> obsConfig,
            ILogger <TwitchBot> logger,
            HubConnection hubConnection,
            HtmlSanitizer sanitizer,
            TwitchMemoryCache twitchMemoryCache,
            TwitchAPI twitchApi,
            IMapper mapper,
            OBSWebsocket obs,
            WLEDService wledService)
        {
            _config        = config.Value ?? throw new MissingConfigException();
            _hubConnection = hubConnection;
            _hubConnection.StartAsync();
            _logger      = logger;
            _sanitizer   = sanitizer;
            _mapper      = mapper;
            _cache       = twitchMemoryCache.Cache;
            _obs         = obs;
            _obsConfig   = obsConfig.Value;
            _wledService = wledService;

            var credentials = new ConnectionCredentials(
                _config.Chat.BotName,
                _config.Chat.PasswordGeneratorToken);

            var clientOptions = new ClientOptions
            {
                MessagesAllowedInPeriod = 750,
                ThrottlingPeriod        = TimeSpan.FromSeconds(30)
            };

            _twitchApiClient = twitchApi;

            var customClient = new WebSocketClient(clientOptions);

            _client = new TwitchClient(customClient);
            _client.Initialize(credentials, _config.Chat.Channel);

            _client.OnConnected           += ClientOnConnected;
            _client.OnJoinedChannel       += ClientOnJoinedChannel;
            _client.OnChatCommandReceived += ClientOnChatCommandReceived;
            _client.OnMessageReceived     += ClientOnMessageReceived;

            _client.Connect();

            SetupOBS();
        }