Hey Guys 
Alright, Today I'm Going To Teach You How To Connect To IRC Servers In C#!
Ready? Good.
Okay, So First Make A New Console Project. Name It Whatever You'd Like.
All Your Code Ready? Awesome.
So Lets Start Off With Adding Some using Statements.
Now That You've Added Those, What Do We Have To Do To Connect? Well Let Me Show You.
In Your Main Function, Add This:
Alright, So We've Connected To The Server, And It Expects Some Data To Be Sent Right Away.
So Right After That, Add This:
Get That? Cool. Now We Can Start Sending And Receiving Data From The Server.
So Next We Want To Put In This:
Did You Understand All That? Cool!
So Now A Bot, Your Bot, Will Join Your Channel, And Reply To You!
If It Works, Awesome Job! If Not, Read Through The Tutorial And Try Again! But If You Still Have Problems, Feel Free to Message Me
Please Note!: All Of the Data Is RAW IRC, So It's Not The Fancy <UserName>: Message, It's :UserName!DNS ... Etc (You'll Understand What I Mean Once you Look At It) So You May Want To Find A Way To Parse The Message!
I Also Want To Mention That Raw IRC Commands Don't Begin With / They Are Normally CAPITAL Versions Of What You'd Type After /
I Hope I Helped
If You Liked It, Don't Forget To Say Thanks

Alright, Today I'm Going To Teach You How To Connect To IRC Servers In C#!
Ready? Good.
Okay, So First Make A New Console Project. Name It Whatever You'd Like.
All Your Code Ready? Awesome.
So Lets Start Off With Adding Some using Statements.
Code:
using System.IO; //For Reading/Writing To The Server
using System.Net.Sockets; //Connecting To The ServerNow That You've Added Those, What Do We Have To Do To Connect? Well Let Me Show You.
In Your Main Function, Add This:
Code:
TcpClient Client = new TcpClient("irc.server.here", 6667); //The Normal IRC Port Is 6667, However Yours May Be Different
NetworkStream NwStream = Client.GetStream(); //Get The TCP/Network Stream And Assign It To NwStream
StreamReader Reader = new StreamReader(NwStream); //Read The Data From The IRC Server
StreamWriter Writer = new StreamWriter(NwStream); //Write To The ServerAlright, So We've Connected To The Server, And It Expects Some Data To Be Sent Right Away.
So Right After That, Add This:
Code:
Writer.WriteLine("USER Name IRCServerName Domain Description"); //This Gives The Server The Required USER Information.
//Note- Replace IRCServerName With The [irc].server.here And Domain With irc.[server].here
//[Example Would Be USER wesnr verne freenode Wesnr] The Server Address Is verne.freenode.net, So You Should Be Able To Put It Together :)
//If There's More Than One Word In The Description, Put : Before It
Writer.Flush(); //VERY IMPORTANT!!! Make Sure You Flush EACH Time After You Write Something To The Stream!
Writer.WriteLine("NICK NickName"); //Supply NickName
Writer.Flush();
Writer.WriteLine("JOIN #Channel"); //Joins The Channel Specified.Get That? Cool. Now We Can Start Sending And Receiving Data From The Server.
So Next We Want To Put In This:
Code:
string Data = ""; //To Receive Data
while((Data = Reader.ReadLine()) != null) //While We're Not Getting Any Null Information From The Server
{
Console.WriteLine(Data); //Write Out Raw IRC Data
if(Data.Contains(".SayHi!")) //If The Data Contains .SayHi!
{
Writer.WriteLine("PRIVMSG #Channel :Hello, Everyone!"); //Write Out to The Channel "Hello, Everyone!" [The : Is To Tell It That There Are Spaces In The Message]
Writer.Flush(); //Don't Forget! :D
}
else
{
Writer.WriteLine("PRIVMSG #Channel :Wuzzat?"); //I'm Guessing You Can Understand What That Does :P
Writer.Flush();
}
}Did You Understand All That? Cool!
So Now A Bot, Your Bot, Will Join Your Channel, And Reply To You!
If It Works, Awesome Job! If Not, Read Through The Tutorial And Try Again! But If You Still Have Problems, Feel Free to Message Me

Please Note!: All Of the Data Is RAW IRC, So It's Not The Fancy <UserName>: Message, It's :UserName!DNS ... Etc (You'll Understand What I Mean Once you Look At It) So You May Want To Find A Way To Parse The Message!

I Also Want To Mention That Raw IRC Commands Don't Begin With / They Are Normally CAPITAL Versions Of What You'd Type After /

I Hope I Helped

If You Liked It, Don't Forget To Say Thanks



















Anurag.



![[-] [-]](images/tech//collapse.gif)


