My bot had connected to IRC fine, althouth I keep getting "Register first" it still managed to connect. But now it's refusing to connect as it's asking me for QUOTE PASS [numbers] so I wrote a bit of code to deal with this and it doesnt seem to work, I have no idea why. Here is the code & commented.
Code:Imports System.Net.Sockets Imports System.IO Imports System.Net Imports System.Threading Module irc Private ircServer As String = "us.undernet.org" Private ircPort As Integer = 6667 Private ircNick As String = "mybot16" Private ircRealName As String = "mybot" Private ircChannel As String = "#mybot16" Dim Invisible As Boolean Private ircConnection As TcpClient Private ircStream As NetworkStream Private ircWriter As StreamWriter Private ircReader As StreamReader Sub main() ' Connect with the IRC server. IrcConnection = New TcpClient(IrcServer, IrcPort) IrcStream = IrcConnection.GetStream() IrcReader = New StreamReader(IrcStream) IrcWriter = New StreamWriter(IrcStream) ' Authenticate bot ircWriter.WriteLine("USER Guest Guest Guest :bot User") IrcWriter.Flush() ircWriter.WriteLine("NICK " & ircNick) ircWriter.Flush() ' Listen for commands Do Dim ircCommand As String ircCommand = IrcReader.ReadLine() Do While ircCommand IsNot Nothing Debug.Print(ircCommand) Dim commandParts(ircCommand.Split(" "c).Length - 1) As String commandParts = ircCommand.Split(" "c) If commandParts(0).Substring(0, 1) = ":" Then commandParts(0) = commandParts(0).Remove(0, 1) End If If commandParts(0) = "PING" Then ' Server PING, send PONG back IrcPing(commandParts) End If ' Normal message If InStr(ircCommand, "PASS") Then quotepass(commandParts(16)) End If Try Dim commandAction As String = commandParts(3) commandAction = commandAction.Replace(":", "") Select Case commandAction Case "!JOIN" joinchan(commandParts(4)) End Select Catch ex As Exception End Try ircCommand = ircReader.ReadLine() ircWriter.WriteLine("JOIN " & ircChannel) ircWriter.Flush() Loop IrcWriter.Close() IrcReader.Close() IrcConnection.Close() Loop End Sub ' Connect Private Sub IrcPing(ByVal IrcCommand() As String) Dim PingHash As String = "" For intI As Integer = 1 To IrcCommand.Length - 1 PingHash &= IrcCommand(intI) & " " Next intI ircWriter.WriteLine("PONG " & PingHash) ircWriter.Flush() End Sub ' IrcPing Sub joinchan(ByVal chan As String) ircWriter.WriteLine("JOIN " & chan) ircWriter.Flush() MsgBox(chan) End Sub 'QUOTE / PASS Sub quotepass(ByVal pass As Integer) ircWriter.WriteLine("QUOTE PASS " & pass) ircWriter.Flush() MsgBox("QUOTE PASS " & pass) 'this seems to be correct. End Sub End Module




Reply With Quote