Example #1
0
        public TwitchClientService(
            TwitchSettings settings,
            HubConnection connection,
            TrelloService trelloService)
        {
            _settings      = settings;
            _connection    = connection;
            _trelloService = trelloService;
            _connection.StartAsync();


            ConnectionCredentials credentials = new ConnectionCredentials(_settings.BotName, _settings.AuthToken);
            var clientOptions = new ClientOptions
            {
                MessagesAllowedInPeriod = 750,
                ThrottlingPeriod        = TimeSpan.FromSeconds(30)
            };
            WebSocketClient customClient = new WebSocketClient(clientOptions);

            _client = new TwitchClient(customClient);
            _client.Initialize(credentials, _settings.Channel);
            _client.OnLog                 += Client_OnLog;
            _client.OnJoinedChannel       += Client_OnJoinedChannel;
            _client.OnChatCommandReceived += Client_OnCommandReceived;
            _client.OnWhisperReceived     += Client_OnWhisperReceived;
            _client.OnRaidNotification    += Client_OnRaidNotification;
            _client.OnNewSubscriber       += Client_OnNewSubscriber;
            _client.OnGiftedSubscription  += Client_OnGiftSubscriber;
            _client.OnConnected           += Client_OnConnected;

            _client.Connect();
        }