Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Net.Sockets;
- using System.Threading;
- namespace BotFramework
- {
- class Program
- {
- static string username;
- static string password;
- static string channel;
- static string messagePrefix;
- static StreamReader reader;
- static StreamWriter writer;
- static TcpClient tcpClient;
- static void Main(string[] args)
- {
- username = "TheRealFloxDBot";
- password = "Token";
- channel = "TheRealFloxD";
- messagePrefix = ":" + username + "!" + username + "@" + username + ".tmi.twitch.tv PRIVMSG " + channel + " :";
- if (Connect())
- {
- Thread t1 = new Thread(GetMessages);
- Thread t2 = new Thread(WriteMessages);
- }
- }
- static bool Connect()
- {
- try
- {
- tcpClient = new TcpClient("irc.twitch.tv", 6667);
- reader = new StreamReader(tcpClient.GetStream());
- writer = new StreamWriter(tcpClient.GetStream());
- writer.WriteLine("PASS " + password);
- writer.WriteLine("NICK " + username);
- writer.WriteLine("USER " + username + " 8 * :" + username);
- writer.WriteLine("JOIN " + channel);
- writer.Flush();
- return true;
- }
- catch
- {
- return false;
- }
- }
- static void GetMessages()
- {
- while(true)
- {
- if (reader.Peek() >= 0)
- {
- Console.WriteLine(reader.ReadLine());
- }
- Thread.Sleep(100);
- }
- }
- static void WriteMessages()
- {
- while (true)
- {
- writer.WriteLine(messagePrefix + Console.ReadLine());
- writer.Flush();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement