public async void StartTwitchApi() { myTwitchApi = new TwitchAuth(); await myTwitchApi.AuthCheck(); // await TaskEx.WaitUntil(myTwitchApi.HasToken); api = new TwitchAPI(); api.Settings.ClientId = myTwitchApi.ClientId(); api.Settings.AccessToken = myTwitchApi.Token(); StartChat(); }
public void StartChat() { if (client != null) { client = null; } ConnectionCredentials credentials = new ConnectionCredentials(getUserNameApi(), myTwitchApi.Token()); var clientOptions = new ClientOptions { MessagesAllowedInPeriod = 750, UseSsl = true, ThrottlingPeriod = TimeSpan.FromSeconds(30) }; WebSocketClient customClient = new WebSocketClient(clientOptions); client = new TwitchClient(customClient); client.Initialize(credentials, getUserNameApi(), '!'); client.OnLog += Client_OnLog; // client.OnJoinedChannel += Client_OnJoinedChannel; client.OnMessageReceived += Client_OnMessageReceived; client.OnWhisperReceived += Client_OnWhisperReceived; client.OnNewSubscriber += Client_OnNewSubscriber; client.OnUserJoined += Client_OnUserJoined; client.OnUserLeft += Client_OnUserLeft; // client.OnUserStateChanged += ClientUsers; client.Connect(); }