Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Net.Sockets;
  11. using System.IO;
  12.  
  13.  
  14. namespace Bot
  15. {
  16. public partial class Form1 : Form
  17. {
  18. TcpClient tcpClient;
  19. StreamReader reader;
  20. StreamWriter writer;
  21.  
  22. public Form1()
  23. {
  24. InitializeComponent();
  25. Reconnect();
  26. }
  27.  
  28. private void Reconnect()
  29. {
  30. tcpClient = new TcpClient("irc.chat.twitch.tv", 6667);
  31. reader = new StreamReader(tcpClient.GetStream());
  32. writer = new StreamWriter(tcpClient.GetStream());
  33.  
  34. var userName = "rworrell1_bot";
  35. var password = File.ReadAllText("password.txt");
  36.  
  37. writer.WriteLine("PASS " + password);
  38. writer.WriteLine("NICK " + userName);
  39. writer.WriteLine("USER " + userName + " 8 * :" + userName);
  40. writer.Flush();
  41. writer.WriteLine("JOIN #rworrell1");
  42. writer.Flush();
  43. }
  44.  
  45. void timer1_Tick(object sender, EventArgs e)
  46. {
  47. if (!tcpClient.Connected)
  48. {
  49. Reconnect();
  50. }
  51.  
  52. if (tcpClient.Available > 0 || reader.Peek() >= 0)
  53. {
  54. var message = reader.ReadLine();
  55. chat.Text += $"\r\n{message}";
  56. }
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement