Advertisement
Guest User

bot

a guest
May 12th, 2016
621
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Net.Sockets;
  7. using System.Net;
  8. using System.IO;
  9.  
  10. namespace ConsoleApplication1
  11. {
  12.     class IrcClient
  13.     {
  14.         private string userName;
  15.         private string channel;
  16.  
  17.         private TcpClient tcpClient;
  18.         public StreamReader inputStream;
  19.         public StreamWriter outputStream;
  20.  
  21.         public IrcClient(string ip, int port, string userName, string password)
  22.         {
  23.             this.userName = userName;
  24.             tcpClient = new TcpClient(ip, port);
  25.             inputStream = new StreamReader(tcpClient.GetStream());
  26.             outputStream = new StreamWriter(tcpClient.GetStream());
  27.  
  28.             outputStream.WriteLine("PASS " + password);
  29.             outputStream.WriteLine("NICK " + userName);
  30.             outputStream.WriteLine("USER " + userName + "8 * :" + userName);
  31.             outputStream.Flush();
  32.         }
  33.  
  34.         public void joinRoom(string channel)
  35.         {
  36.             this.channel = channel;
  37.             outputStream.WriteLine("JOIN #" + channel);
  38.             outputStream.Flush();
  39.         }
  40.  
  41.         public void sendIrcMessage(string message)
  42.         {
  43.             outputStream.WriteLine(message);
  44.             outputStream.Flush();
  45.         }
  46.  
  47.         public void sendChatMessage(string message)
  48.         {
  49.             sendIrcMessage(":" + userName + "!" + userName + "@" + userName + ".tmi.twitch.tv PRIVMSG #" + channel + " :" + message);
  50.         }
  51.  
  52.         public string readMessage()
  53.         {
  54.             string message = inputStream.ReadLine();
  55.             return message;
  56.         }
  57.     }
  58. }
Advertisement
RAW Paste Data Copied
Advertisement