# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  IRC Bot Source Code

## plenderj

[ edit 15/08/2006 ]
Please see here:
http://www.vbforums.com/showthread.php?p=2583859
[ /edit ]

[ edit 23/01/2007 ]
Please see here:
http://plenderj.com/files/IRCBot.1.0.6.zip
[/edit]

Here is the source code to a IRC Bot I've been coding over the past few days.
It can get onto IRC, send and receive files via DCC, reply to CTCP queries, join channels, give people +o or +v if supplied with the right password ...

It should also be very easy to modify the source code to add your own features etc.

As always, if you've any queries or comments just contact me.

----------


## plenderj

* 21-October-2004 - Moved to CodeBank *

----------


## TRIBAL-PHoENiX

hey i tryed running your bot and well it doesnt work for me, i ran it with the default config and i got this error "Run-Time Error '40020': Invalid operation at current state, then i changed the config file with this 
=================================
set nickname = testbot
set altnick = bot2
set connectToIRC = true
set dccPass = password
set quitMessage = Mwaaahhhhhhhhhhh
set attemptedCPS = 4096

Servers {
	2600net:6667
}

InitiallySend {
	JOIN #testing1
	OPER admin password
}
===============================
and still get the same error

----------


## plenderj

Well bear in mind the code is based on the IRC protocol of over 3 years ago - I don't know if much has changed in the meantime...

----------


## plenderj

Its a _No Route To Host_ error. By the looks of it there is no IRC Server running on the host 2600.net

----------


## scope-of-dread

:Big Grin:  Just thought id see how your bot worked in 2006 july - well it works fine still logs in joins channel no problems at all.  IRC hasnt really changed much at all in years, and is unlikely to change much in the future, some new parts are added but overall its still the same base.

----------


## plenderj

Thanks  :Smilie:  The source code is actually hacked down to a generic enough form from an IRC bot project I created to do some pretty specific stuff online. There's some parts of the code that don't really make sense or aren't applicable...

... come to think of it I should probably write a vb.net version of it...

----------


## plenderj

By the way I'm coding a brand new bot from scratch in VB.NET

----------


## plenderj

http://www.vbforums.com/showthread.php?p=2583859

----------


## CyberInfantry

I'm checking out this bot and running it through step by step.  I think I understand what it's doing, but not quite why/how.

Also, I'm trying to get it to where it picks up one what people say in the main room, run some calculations based on the input, and spit it back out.

I want this to occur in the main room, not in a private message.

I'm trying to figure out the sckServer.DataArrival part; I think that is the key for what I am looking for.

Basically, I'm wanting it to work so that the following happens:

<Joe_Schmoe> !roll 5
Bot catches "Joe_Schmoe", the "!roll" command, and "5".  Bot creates 5 random numbers within a pre-determined range and sends back the following to the room for all to see:

<Bot_Test> <Joe_Schmoe> rolled 5 dice:  #, #, #, #, #.


Really all I'm needing help on is figuring out how to catch the input and send the output.


Thanks!

----------


## plenderj

You should really look at the new versions:
http://plenderj.com/files/

----------


## CyberInfantry

It appears that is in .NET?  Am I wrong?

While I have an academic version of .NET, I've never learned it... I don't know how different it is from VB 6.0, but 6.0 (Well, and Java) is the only thing I've worked with. :/

----------


## plenderj

Very similar for the most part to VB6 actually

----------


## plenderj

Looking at your other posts, if you used my VB.NET version you could modify this part in Core/BotCore.vb



```
                        Select Case objMessages(i).Command
                            Case "376"
                                Config.LiveInformation.IRCConnected = True

                            Case "PRIVMSG"
                                If objMessages(i).Request.StartsWith(":DCC CHAT") Then
                                    Dim myDCCRequest As New DCCRequest(objMessages(i).Request)
                                    If myDCCRequest.IsValid Then
                                        CreateNewDCCConnection(myDCCRequest)
                                    End If
                                End If
                        End Select
```

And put in a _Case Else_ statement and look for the !roll command etc

----------


## CyberInfantry

I think I've gotten the code from the VB 6.0 one pretty much figured out.  :Big Grin:   It can do all the commands that I want it to do now (for now).

Excellent program.  :Smilie:

----------


## mustiback

ThanKs!!!

----------


## SNIPER.PS

thank you very much

----------


## GGGuardian

Nice share thanks will come in handy  :Big Grin:

----------

