Bot for IRC
Bot for IRC
Bot for IRC
Bot for IRC
Bot for IRC
Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC
Bot for IRC Bot for IRC
Bot for IRC
Go Back  Xtreme Visual Basic Talk > > > Bot for IRC


Reply
 
Thread Tools Display Modes
  #1  
Old 04-19-2003, 03:01 PM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Thumbs up Bot for IRC


Hi All!
I am trying to make a bot for the BobNet IRC, and I am starting in VB using the Winsock IRC control.
I've got this code:
Code:
Private Sub Form_Load() sckIRC.Connect "irc.visualbasicforum.com", "6667" End Sub Private Sub sckIRC_DataArrival(ByVal bytesTotal As Long) sckIRC.GetData DataString, vbString Debug.Print DataString sckIRC.SendData "NICK NiBBot" & vbCrLf sckIRC.SendData "USER NippooBot . . :Winsock IRC client" & vbCrLf If (Left$(DataString, Len("PING :"))) = "PING :" Then sckIRC.SendData Replace(DataString, "PING :", "PONG:") & vbCrLf Debug.Print Replace(DataString, "PING :", "PONG:") & vbCrLf End If End Sub
When I run the program: the Debug window prints:
:irc.visualbasicforum.com NOTICE AUTH :*** Looking up your hostname...

:irc.visualbasicforum.com NOTICE AUTH :*** Found your hostname (cached)
:irc.visualbasicforum.com NOTICE AUTH :*** Checking ident...
:irc.visualbasicforum.com NOTICE AUTH :*** Checking for open socks server...

:irc.visualbasicforum.com NOTICE AUTH :*** No ident response; username prefixed with ~

:irc.visualbasicforum.com NOTICE NiBBot :*** If you are having problems connecting due to ping timeouts, please type /quote pong 6FEB1C or /raw pong 6FEB1C now.
PING :6FEB1C
ERROR :Closing Link: NiBBot[81.77.142.120] (Ping timeout)


What have I done wrong for it not to Pong?
Reply With Quote
  #2  
Old 04-19-2003, 03:38 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

Hi nippoo

First I suggest you make sure the socket is connected before continuing

try something like this or also it may be an idea to put some error code in here as well:

Code:
Do While sckIRC.State <> sckConnected DoEvents if sckIRC.state = sckError then msgbox "An error has occurred" sckIRC.close End ' This will terminate the program end if Loop

As I have never used the irc.visualbasicforum.com its pretty hard to say from there what to do, but what i would do is Comment out (') all your code in the Data_Arrival procedure part from these two lines:

Code:
sckIRC.GetData DataString, vbString Debug.Print DataString

In every sent line there must be something you can check for(when data returns) so you in turn can send the next line, that is probably the reason its not work right at the present moment in time.

the pig.
Reply With Quote
  #3  
Old 04-20-2003, 08:09 AM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

It seems not to work
I have set Debug to print the Pong replies as well... It doesn't seem to recognise the Ping, as Debug doesn't print the Pong...
I think it is a problem with the Left$ line...
Reply With Quote
  #4  
Old 04-20-2003, 10:40 AM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

The dataArrival event will only fire if you are successfully connected, so if you are receiving data from this event (procedure) You have achieved the first part.

You can always post your program here and we may be able to help you.

the pig..
Reply With Quote
  #5  
Old 04-20-2003, 10:52 AM
Csharp's Avatar
CsharpBot for IRC Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Default

you cant send "PONG" on irc , you need to send "PING" BACK
eg: if you receive "PING #channelname " you need to do something like this...

Code:
Socket.SendData "PING " & channelname & vbcrlf

an example of how i do it on msn chat is this ...
Code:
If Left(strData, 4) = "PING" Then SendIt ("PING " & RoomName & vbCrLf)'SENDIT POINTS TO A MODULE AND HANDLES SOCKET.SEND IN THIS CASE DoEvents End If
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
  #6  
Old 04-20-2003, 11:08 AM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Sounds like you are using the irc example from www.winsockvb.com . Here is your problem. When the server sends you a PING you must reply PONG or the server will kick you off, but it is not that easy. The server will send PING: HexNumber. You must reply to the server with PONG: SameHexNumber.

Now the tutorial will work fine for every server EXCEPT irc.visualbasicforum.com. The visualbasicforum server has a nasty habit of making things run togther. So you need to split all the incoming data at the control line feeds(vbcrlf) and read the first 4 characters of each spot in the array. If it equals Ping replace PING with PONG and send the whole string back.
Reply With Quote
  #7  
Old 04-20-2003, 11:15 AM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

Here is the project, hope you can help...
Attached Files
File Type: zip prjBot.zip (1.6 KB, 42 views)
Reply With Quote
  #8  
Old 04-20-2003, 12:28 PM
Csharp's Avatar
CsharpBot for IRC Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Default

i see one problem you will face , in the sckIrc data arrival sub , you have the following code...
Code:
Private Sub sckIRC_DataArrival(ByVal bytesTotal As Long) sckIRC.GetData DataString, vbString txtHappening.Text = txtHappening.Text & DataString & vbNewLine '/// sckIRC.SendData "NICK NiBBot" & vbCrLf sckIRC.SendData "USER NippooBot . . :Winsock IRC client" & vbCrLf '//EACH TIME YOU RECEIVE DATA IT WILL TRY TO SEND THE NICK AND USER COMMAND. If (Left$(DataString, (Len("PING :")))) = " PING :" Then sckIRC.SendData Replace(DataString, "PING :", "PONG:") & vbCrLf Debug.Print Replace(DataString, "PING :", "PONG:") & vbCrLf End If End Sub
you need to send the user / nick command in sckIRC_Connect()

something like this
Code:
Dim DataString As String Private Sub Form_Load() sckIRC.Connect "irc.visualbasicforum.com", 6667 End Sub Private Sub sckIRC_Connect() sckIRC.SendData "NICK NiBBot" & vbCrLf sckIRC.SendData "USER NippooBot . . :Winsock IRC client" & vbCrLf End Sub Private Sub sckIRC_DataArrival(ByVal bytesTotal As Long) sckIRC.GetData DataString, vbString With txtHappening .SelStart = Len(.Text) .SelText = DataString & vbCrLf End With If Left(DataString, 4) = "PING" Then sckIRC.SendData Replace(DataString, "PING :", "PONG:") & vbCrLf End If End Sub
but i notice it's asking for a socks server and thats the problem you appear to be having not a PING problem.
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
  #9  
Old 04-20-2003, 12:36 PM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

I've put your code... but it STILL doesn't work
I've put:
Code:
If Left(DataString, 4) = "PING" Then MsgBox "blah" End If

... and when the PING comes it doesn't display the MsgBox...
I really don't know why...
Reply With Quote
  #10  
Old 04-20-2003, 12:44 PM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Because the PING will not always be on the first four characters of the arriving data. Try this.

Code:
dim temp() as string dim X as Integer temp = split(DataString,vbcrlf) for X = 0 to Ubound(temp) If Left(temp(X), 4) = "PING" Then MsgBox "blah" End If Next X

The ping will always be at the first four characters of the line but several lines could come at once.
Reply With Quote
  #11  
Old 04-20-2003, 12:49 PM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

jeez, thanks!
I can now get the MOTD, and connect to a channel!
Reply With Quote
  #12  
Old 04-20-2003, 12:55 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

here's my version of it for you.

comment out which one you dont want to use.


the pig..
Attached Files
File Type: zip bot.zip (1.9 KB, 67 views)
Reply With Quote
  #13  
Old 04-20-2003, 12:57 PM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

Oh... and one last question... how do you make it join a channel?
I've tried sckIRC.SendData "/join #visualbasicforum" but it doesn't work...
Reply With Quote
  #14  
Old 04-20-2003, 01:11 PM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

The "/" are to make IRC user friendly. To join #visualbasicforum you send "JOIN #visualbasicforum"
Reply With Quote
  #15  
Old 04-20-2003, 01:29 PM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

Code:
sckIRC.SendData "JOIN #visualbasicforum"
doesn't seem to work...
Reply With Quote
  #16  
Old 04-20-2003, 02:09 PM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Humm. Well look here. That works for me so I don't know.
Reply With Quote
  #17  
Old 04-20-2003, 02:52 PM
MindGenius MindGenius is offline
Banned
 
Join Date: Sep 2003
Location: London, United Kingdom
Posts: 392
Default

hmmm... Well, there is no point connecting if I can't join a channel...
Piggybank.... apples grow from acorns?
Reply With Quote
  #18  
Old 04-20-2003, 03:34 PM
Csharp's Avatar
CsharpBot for IRC Csharp is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Location: Ashby, Leicestershire.
Posts: 967
Default

Quote:
sckIRC.SendData "JOIN #visualbasicforum"
are you putting the return at the end ( vbcrlf ) like this
Code:
sckIRC.SendData "JOIN #visualbasicforum" & vbcrlf
__________________
~~ please don't PM me regarding code, I only reply to personnal messages ~~
Reply With Quote
  #19  
Old 04-20-2003, 04:02 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

nippoo, you never asked about joining a channel before i sent the file in!!

the pig..
Reply With Quote
  #20  
Old 04-20-2003, 07:51 PM
rust710 rust710 is offline
Contributor
 
Join Date: Oct 2002
Location: Michigan, USA
Posts: 516
Default

Control line feed. I always forget about those in IRC protocol.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Bot for IRC
Bot for IRC
Bot for IRC Bot for IRC
Bot for IRC
Bot for IRC
Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC Bot for IRC
Bot for IRC
Bot for IRC
 
Bot for IRC
Bot for IRC
 
-->