This client uses an activx control (OCX) so add the winsock control to your project.
Declare your form as: Option Explicit
Now let's assume that you winsock control that u have addeded to your form is called sckIRC
Make sure to add the folowing code to form load sub:
With sckIRC .RemoteHost = "irc.someircserver.com" 'The IRC server here .RemotePort = 6667 'Connect on port 6667 (Normal port for irc) .Connect End WithThe next sub will be the one when sckIRC will connect to irc.
With sckIRC .SendData "NICK your_nick" & vbCrLf .SendData "USER your_nick " & sckIRC.LocalHostName & " " & _ UCase(sckIRC.LocalHostName & ":" & sckIRC.LocalPort & "/0") & " :Winsock Client" & vbCrLf .SendData "JOIN #yourChanHere" & vbCrLf End With
Now add to your form a textbox called txtBuffer
The folowing code will make sure that you won't ping time out. It's a very important sub, it will reply to the ircServer PONG when this one PING your client.
Private Sub sckIRC_DataArrival(ByVal bytesTotal As Long) On Error Resume Next Dim sRecv As String sckIRC.GetData sRecv If Split(sRecv, " ")(0) = "PING" Then sckIRC.SendData "PONG " & Split(sRecv, " ")(1) End If 'Update your text box with the new data that you have received txtBuffer.Text = txtBuffer.Text & sRecv & vbCrLf txtBuffer.SelStart = Len(txtBuffer.Text) End SubDonne. at this moment you already have an irc bot. To get build some commands you just need to get the sRecv text from the last sub and manage it.
Data format is:
:NickNameFromWhoWriteInChan!host@ipmask PRIVMSG #chanName :text From the convo
when change #chanName to chanName it will send a private message to chanName (nickName)
This is an exemple on how to build a simple and fast irc bot or irc client, i am not do not assume any reponsability of bad use of this code.