Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ircClient.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace twitchbot
- {
- class ircClient
- {
- private string userName;
- private string channel;
- private TcpClient tcpClient;
- private StreamReader inputStream;
- private StreamWriter outputStream;
- public ircClient(String ip, int port, string userName, string password)
- {
- this.userName = userName;
- tcpClient = new TcpClient(ip, port);
- inputStream = new StreamReader(tcpClient.GetStream());
- outputStream = new StreamWriter(tcpClient.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.tv PRIVMSG #" + channel + " :" + message);
- }
- public string readMessage()
- {
- string message = inputStream.ReadLine();
- return message;
- }
- }
- }
- Program.cs
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using WMPRichPreviewLauncher;
- using WMPLib;
- namespace twitchbot
- {
- class Program
- {
- static void Main(string[] args)
- {
- System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"C:\\Users\\VPSwede\\Desktop\\Dankmemes\\Sounds\\song.wav");
- ircClient irc = new ircClient("irc.twitch.tv", 6667, "vpswedebot", "oauth");
- irc.joinRoom("vpswede");
- while(true)
- {
- string message = irc.readMessage();
- if (message.Contains("PING :tmi.twitch.tv"))
- {
- Console.WriteLine(message);
- irc.sendIrcMessage("PONG tmi.twitch.tv\r\n");
- }
- if (message.Contains("string"))
- {
- //somecode
- }
- else if (message.Contains("string"))
- {
- //somecode
- }
- else
- {
- Console.WriteLine(message);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment