How can I connect to an IRC server and chat. Basically I want to make an IRC program, but with REALLY limited features, can someone describe this process to me?
Printable View
How can I connect to an IRC server and chat. Basically I want to make an IRC program, but with REALLY limited features, can someone describe this process to me?
First of all, you'll need to make a server for the client to connect to(not hard if you use WinSock).
Then you can send messages to the server, which will be displayed on the client programs.
It is difficult to make a server that accepts more that one connection, but I you know WinSock, this will be an easy task! :)
Good luck! :)
check out the attachment
I'll give you something to start, very simple examples and stuff.
Get a new Project, place a Winsock Control (TCP) on it, and a TextBox (txtDisplay). Make the txtDisplay big, get MultiLine to True.
First thing, I'd like to make two Subs before we begin, so I don't have to type that much :D
----------------
Sub Send(Msg)
TCP.SendData Msg & vbNewLine
End Sub
----------------
----------------
Sub Say(Text)
txtDisplay = txtDisplay & Text & vbNewLine
End Sub
----------------
We have to connect to the server first.
-------------------
Private Sub Form_Load()
txtDisplay = ""
If TCP.State <> sckClosed Then TCP.Close
TCP.RemoteHost = "irc.msn.com"
TCP.RemotePort = 6667
TCP.Connect
End Sub
-------------------
There! (I assume you know the basics on the Winsock Control, otherwise just ask! You can find it rightclicking on your control tab on the left, selecting "Components" --> "Microsoft Winsock Control <ver.>".) We are connecting now.
As you probably expect, we must verify on the Connect Event. The server needs to know our nickname and user information.
--------------------
Private Sub TCP_Connect()
Say ">> Connected! Sending Data ..."
Send "NICK MyVBNickname01"
Send "USER [email protected] " _
& TCP.LocalIP & "irc.msn.com :VBIRC-Test"
End Sub
--------------------
Information sent! You're connected! The server probably sends his MOTD (Message Of The Day) and you're ready to go! I'll give you something simple to put every received string in the TextBox, and I think you can make some coding yourself on responding to the strings received (such as nick-changing, parts, joins, whatever).
--------------------
Private Sub TCP_DataArrival
Dim InMSG
TCP.GetData InMSG
Say "Data Received:" & vbNewLine & "---" & vbNewLine & InMSG _
& vbnewline & "---"
' >> Replace it by some codes to respond, and
' >> communicate with the server!!
End Sub
--------------------
That's all there is to it, if you ask me! Some strings you could send at last:
Join a room: Send "JOIN #VisualBasic"
Part a room: Send "PART #VisualBasic"
Change nick: Send "NICK MyNewNick"
Op someone: Send "MODE #VB +o MyLittleFriend"
These are some basic commands!
Hope this will help you with your problem,
Quintonir