private void cmdTrennen_Click(System.Object sender, System.EventArgs e) { if (client.IsConnected) { client.LeaveChannel(txtChannel1.Text); } client.Disconnect(); backgroundWorker1.CancelAsync(); backgroundWorker1.Dispose(); }
public Task Disconnect() { foreach (var joinedChannel in client.JoinedChannels) { client.LeaveChannel(joinedChannel); } client.Disconnect(); return(Task.CompletedTask); }
public async Task StopAsync(CancellationToken cancellationToken) { isShuttingDown = true; if (_twitchClient != null && _twitchClient.IsConnected) { _twitchClient.Disconnect(); } if (_twitchPubSub != null) { _twitchPubSub.Disconnect(); } if (_timer != null) { _timer.Dispose(); } //if (_streamStatusCheck != null) //{ // _streamStatusCheck.Dispose(); //} //if (_followerChatReminder != null) //{ // _followerChatReminder.Dispose(); //} //if (_discordChatReminder != null) //{ // _discordChatReminder.Dispose(); //} //if (_questionChatReminder != null) //{ // _questionChatReminder.Dispose(); //} //if (_primeChatReminder != null) //{ // _primeChatReminder.Dispose(); //} if (_alertHubConnection != null) { if (_alertHubConnection.State == HubConnectionState.Connected) { await _alertHubConnection.StopAsync(); } await _alertHubConnection.DisposeAsync(); } if (_chatHubConnection != null) { if (_chatHubConnection.State == HubConnectionState.Connected) { await _chatHubConnection.StopAsync(); } await _chatHubConnection.DisposeAsync(); } if (_overlayHubConnection != null) { if (_overlayHubConnection.State == HubConnectionState.Connected) { await _overlayHubConnection.StopAsync(); } await _overlayHubConnection.DisposeAsync(); } }
private void ResetConnection_Tick(object sender, EventArgs e) { //This works around an issue with Twitch where the IRC Client gets randomly disconnected., client.Disconnect(); client.Connect(); }
private void OnApplicationQuit() { if (client != null && client.IsConnected) { client.Disconnect(); } }
private void btnDisconnect_Click(object sender, EventArgs e) { Client.Disconnect(); btnConnect.Enabled = true; btnDisconnect.Enabled = false; edtMessage.Enabled = false; btnSend.Enabled = false; webChat.Navigate("about:blank"); tmStream.Enabled = false; lbEmotes.Enabled = false; btnSendEmotes.Enabled = false; speCount.Enabled = false; btnPower.Enabled = false; btnPowerJ.Enabled = false; btnPowerKursive.Enabled = false; btnSend.Enabled = false; edtMessage.Enabled = false; edtUser.Enabled = true; edtChannel.Enabled = true; edtOauth.Enabled = true; pbChannelIcon.Image = null; lblStatus.Text = "-"; lblViewers.Text = "-"; lblGame.Text = "-"; lblLink.Text = "-"; lblName.Text = "-"; RichLog.Clear(); lblLink.Enabled = false; }
private void Stop() { ButtonText = "Start"; ButtonCommand = new DelegateCommand(Start); Running = false; _client.Disconnect(); }
public async Task Disconnect() { _twitchClient.OnDisconnected += TwitchClientOnOnDisconnected; _twitchClient.Disconnect(); await _disconnectionCompletionTask.Task; }
private void TwitchClient_OnMessageSent(object sender, OnMessageSentArgs e) { if (_twitchClient.IsConnected) { _twitchClient.Disconnect(); } }
// Call bot to disconnect internal void Disconnect() { consoleMessage[5] = "Disconnecting"; Program.SendToConsole(consoleMessage); client.Disconnect(); }
public void Stop() { if (kernel.Started) { kernel.Stop(); } Unsubscribe(); tryToReconnect = false; if (client.IsConnected) { client.Disconnect(); } try { listeningToChannelPoints = false; pubsubIsConnected = false; pubsub.Disconnect(); } catch { } broadcastSubscription?.Unsubscribe(); }
private async Task UpdatePassword(string password) { _logger.LogInformation( $"{DateTime.UtcNow.ToString(CultureInfo.CurrentUICulture)}: Updating the Twitch bot password"); var creds = new ConnectionCredentials(_config[Constants.CONFIG_TWITCH_USERNAME], password); try { // IF CONNECTED, DISCONNECT if (_twitchClient.IsConnected) { _logger.LogInformation($"{DateTime.UtcNow.ToString(CultureInfo.CurrentUICulture)}: Disconnecting from Twitch"); _twitchClient.Disconnect(); _logger.LogInformation($"{DateTime.UtcNow.ToString(CultureInfo.CurrentUICulture)}: Disconnected from Twitch"); } // UPDATE THE CLIENT CREDS _twitchClient.SetConnectionCredentials(creds); // RECONNECT TO TWITCH _twitchClient.Reconnect(); _logger.LogInformation($"{DateTime.UtcNow.ToString(CultureInfo.CurrentUICulture)}: Updated the Twitch bot password"); } catch (Exception ex) { _logger.LogError($"{DateTime.UtcNow.ToString(CultureInfo.CurrentUICulture)}: An exception occured: {ex.Message}"); } _logger.LogInformation( $"{DateTime.UtcNow.ToString(CultureInfo.CurrentUICulture)}: Updated the Twitch bot password"); await Task.CompletedTask; }
internal async Task <string> OnApiRequest(JObject request, ILambdaContext context) { var jArray = JArray.Parse(request["Records"].ToString()); var sqsMessages = jArray.ToObject <List <Message> >(); _Logger.LogInformation($"Received SQS Messages: {sqsMessages.ToJsonString()}"); var client = new TwitchClient(new WebSocketClient(new ClientOptions { MessagesAllowedInPeriod = 750, ThrottlingPeriod = TimeSpan.FromSeconds(30) })); client.Initialize(new ConnectionCredentials(TwitchInfos.UserName, TwitchInfos.Token), "Nerdtastic"); client.Connect(); foreach (var sqsMessage in sqsMessages) { var streamResponse = JObject.Parse(sqsMessage.Body).ToObject <StreamEventResponse>(); //log in as our bot //send the message to the user. if (streamResponse.Whisper) { client.SendWhisper(streamResponse.UserName, streamResponse.Response); } else { client.SendMessage(new JoinedChannel(streamResponse.Channel), streamResponse.Response); } } client.Disconnect(); return("Jobs done - fix me"); }
public void DisconnectFromChat() { if (IsActive) { client.Disconnect(); } }
public void Disconnect() { if (client.IsConnected) { client.Disconnect(); } }
public void ClientReconnectsOk() { var client = new TwitchClient(_mockClient); var pauseConnected = new ManualResetEvent(false); var pauseReconnected = new ManualResetEvent(false); Assert.Raises <OnReconnectedEventArgs>( h => client.OnReconnected += h, h => client.OnReconnected -= h, () => { client.OnConnected += (s, e) => { pauseConnected.Set(); client.Disconnect(); }; client.OnDisconnected += (s, e) => { client.Reconnect(); }; client.OnReconnected += (s, e) => { pauseReconnected.Set(); }; client.Initialize(new Models.ConnectionCredentials(TWITCH_BOT_USERNAME, "OAuth")); client.Connect(); ReceivedTwitchConnected(); Assert.True(pauseConnected.WaitOne(5000)); Assert.True(pauseReconnected.WaitOne(60000)); }); }
internal void Disconnect() { Console.WriteLine("[Bot]: Disconnecting..."); points.Save(); usersManager.Save(); client.Disconnect(); }
public void Stop() { TwitchClient.Disconnect(); Active = false; TokenSource.Cancel(); SendingThread.Join(); }
private void Reconnect() { if (_twitch.IsConnected) { _twitch.Disconnect(); } _twitch.Connect(); }
internal void Disconnect() { twitchClient.Disconnect(); if (_botTimer is not null) { _botTimer.Dispose(); } }
private async Task DisconnectAsync() { Messages.Clear(); _client.Disconnect(); IsConnected = false; connectionLight.Fill = Brushes.Red; channelEntryBox.IsEnabled = true; }
/// <summary> /// Disconnects from Twitch. /// </summary> public void Stop() { botClient.Disconnect(); userClient.Disconnect(); followerService.StopService(); liveStreamMonitor.StopService(); IsConnected = false; }
private void disconnect_Click(object sender, RoutedEventArgs e) { client.LeaveChannel(channel); client.Disconnect(); client = null; Chat.Items.Insert(0, "Disconnecting..."); controlListMemory(); }
internal void Disconnect() { CloseExcel(); client.Disconnect(); monitor.Stop(); fservice.Stop(); Console.WriteLine("Disconnecting..."); }
private void Disconnect() { Logger.Instance.LogMessage(TracingLevel.INFO, "TwitchChat: Attempting to disconnect"); if (client != null && client.IsConnected) { client.Disconnect(); } }
public Task StopAsync(CancellationToken cancellationToken) { if (_Client != null) { _Client.Disconnect(); } return(Task.CompletedTask); }
public Task StopAsync(CancellationToken cancellationToken) { _logger.LogDebug("Chat update service is stopping."); _client.Disconnect(); return(Task.CompletedTask); }
/// <summary> /// Connects a TwitchClient to a specified twitch chat, and listens for chat events /// </summary> public void GetChat() { //if a connection is already esablished prior to trying to connecting another channel, //disconnect client and reset credentials try { client.Disconnect(); client = null; credentials = null; } catch (Exception) { } //sets the channel name that the client will connect to channel_name = channelInput.Text.ToLower(); //creates client credentials from access tokens and bot username credentials = new ConnectionCredentials(BOT_CHANNEL_NAME, BOT_ACCESS_TOKEN); //creates new empty client client = new TwitchClient(); //subs to log event to display client logs in the output window client.OnLog += Client_OnLog; //initialize client using credentials, and tell it what channel it will be going to. client.Initialize(credentials, channel_name); //subscribe to any events we want our bot to listen for //subs to new chat messsage client.OnMessageReceived += MyMessageRecieved; client.OnWhisperReceived += WhisperRecieved; //subs to client connected client.OnConnected += Client_OnConnected; //subs to chat commands client.OnChatCommandReceived += Client_OnChatCommandReceived; //conencts client to specified twitch channel client.Connect(); }
internal void Disconnect() { form.ExecuteAction(() => { form.DebugRichTextBox.AppendText("[Bot]: Disonnecting and closing application\n"); }); client.Disconnect(); }
public void BotStop() { client.Disconnect(); isConnected = false; window.Dispatcher.Invoke((Action)(() => {//this refer to form in WPF application window.BotStopped(); })); }