Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.Net.Sockets;
- using System.IO;
- namespace TwitchmIRCbot
- {
- class IrcClient
- {
- private string UserName;
- private string Channel;
- private TcpClient TPCClient;
- private StreamReader InputStream;
- private StreamWriter OutputStream;
- public IrcClient(string ip, int port, string username, string password)
- {
- this.UserName = username;
- TPCClient = new TcpClient(ip, port);
- InputStream = new StreamReader(TPCClient.GetStream());
- OutputStream = new StreamWriter(TPCClient.GetStream());
- OutputStream.WriteLine("PASS " + password);
- OutputStream.WriteLine("NICK " + username);
- OutputStream.WriteLine("USER " + username + " 8 * :" + username);
- OutputStream.Flush();
- }
- public void joinRoom(string channel)
- {
- this.Channel = channel;
- OutputStream.WriteLine("JOIN #" + channel);
- OutputStream.Flush();
- }
- public void SendIrcMessage(string message)
- {
- OutputStream.WriteLine(message);
- OutputStream.Flush();
- }
- public void SendChatMessage(string message)
- {
- SendIrcMessage(":" + UserName + "!" + UserName + "@" + UserName + ".tmi.twitch PRIVMSG #" + Channel + " :" + message);
- }
- public string ReadMessage()
- {
- string message = InputStream.ReadLine();
- return message;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment