Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Net;
- using System.Net.Sockets;
- using System.IO;
- using System.Threading;
- using System.Text.RegularExpressions;
- using System.Runtime.InteropServices;
- using System.Media;
- using System.Diagnostics;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- #region variables
- public static string userName = "blahblah";
- public static string password = "oauth:blahblah";
- private static IrcClient irc = new IrcClient("irc.chat.twitch.tv", 6667, userName, password);
- NetworkStream serverStream = default(NetworkStream);
- string readData = "";
- Thread chatThread;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- irc.joinRoom("larklen");
- chatThread = new Thread(getMessage);
- chatThread.Start();
- }
- private void getMessage()
- {
- serverStream = irc.tcpClient.GetStream();
- int buffsize = 0;
- byte[] inStream = new byte[10025];
- buffsize = irc.tcpClient.ReceiveBufferSize;
- while (true)
- {
- try
- {
- readData = irc.readMessage();
- msg();
- }
- catch (Exception)
- {
- }
- }
- }
- private void msg()
- {
- if (this.InvokeRequired) this.Invoke(new MethodInvoker(msg));
- else
- {
- string[] separator = new string[] { "#larklen :" };
- string[] singlesep = new string[] { ":", "!" };
- if (readData.Contains("PRIVMSG"))
- {
- string username = readData.Split(singlesep, StringSplitOptions.None)[1];
- string message = readData.Split(separator, StringSplitOptions.None)[1];
- richTextBox1.Text = richTextBox1.Text + username + "> " + message + Environment.NewLine;
- int num = richTextBox1.Lines.Count();
- if (richTextBox1.Lines.Count() > 301)
- {
- var foos = new List<string>(richTextBox1.Lines);
- foos.RemoveAt(0);
- richTextBox1.Lines = foos.ToArray();
- }
- }
- }
- }
- }
- }
- #endregion
Add Comment
Please, Sign In to add comment