THE UNDERNET BOTDOCS: An introduction to IRC Bots Disclaimer: I wrote this, anything that you do because of this document is your problem. Feel free to distribute this but leave it alone. Don't change my words, let me screw this up own my own and never charge money for this. Super dglow@undergrad.math.uwaterloo.ca dgl@titan.ccm.emr.ca bq206@freenet.carleton.ca ------------------------------------------------------------------------------- What should I know before reading this? The most important thing is to know what IRC is. If you are not sure, check out the usenet group alt.irc, or pick up your favorite guide to the Internet. The second step is to read an IRC primer of some sort. Check out the ftp site sci.dixie.edu in /pub/irc/docs for more info on all of this or on IRC check out some of the help services on #help. What the heck is a bot? This is one of the most common questions that appears on channels or newsgroups dealing with IRC. Bots are clients that have automated responses to certain commands (they are just a bunch of scripts). Confused? You should be. Hopefully this will be clear as we continue. How does a bot work? Normally a bot contains scripts of "on" commands. A simple one that people use in their clients is: on join * /whois $0 This what this does is tell you who the person is when they join a channel. That is how a bot works. How is a bot run? Bots are seperate processes from your normal client (however you can be the bot if you wish by simply loading the bot script into your client with a /load). What good is a bot? There are various opinions on what bots are good for. Most people use bots to aid in controlling a channel. Most bots control the distribution of ops through an oplist. Bots can also be great information tools such as Helpbot (which sends out help documents like this). Does this mean bots can do more than I can? No, bots are just users, they can only do what you have access to. So running a bot does not mean you can get ops on a channel that you don't presently have ops on. What about these "Warbots"? There are a lot of malicious people out there that have created bots that "take over channels". In most cases this is not true. What these bots are designed to do is join a channel and try and force a netsplit to get ops or flood out all of the users on the channel. Fortunately on Undernet, time stamping prevents this from happening (see the Undernet FAQ for more info). Running bots that are malicious will get your site K-lined pretty fast which means you (and everyone else from your site) will not be allowed to connect to IRC servers. Good rule of thumb: Don't run warlike/malicious bots. Hopefully by now you know what a bot is, so your next question is where can I get one from? There are a lot of different bots out there. These bots were all written by other people. As described above, there are malicious people out there, some of them must have written bots that aren't warlike, but do have backdoors. What this means is they (or someone else) can take over your bot, and most likely be able get access to your account from this. How can they do this? Simple, remember, bots are just like you. They have access to the same stuff you do, so they can do the same things as you. When you are on IRC, you can do everything and anything to your account. Well so can your bot. If you run a bot that someone else wrote, it is possible that you are allowing them (or someone else) access to your account through the bot. What are you trying to say? If you are going to run someone elses bot, read through the script. Find out what it is doing. Better yet, run your own bot. Write it yourself to do things you want to do. One day someone might want to run the bot you write. Ok, so how do I write this thing? There are many different ways to write it. Bots can be written in many different languages, such as Perl, C and ircII. If you are just starting out ircII is the best language to pick because it is the most common client that people use to IRC from and it is something that can be easily tested and debugged. I am still unsure of how to write a bot, can you give me another hint? Sure. The best way to start is to read the irc help manual and understand how /on commands work. From there you can also learn how set commands and other commands work. The next step is write a script to use from your client. Do I want a bot? This is not really a frequently asked question but it should be. It seems that a lot of people want bots but have no clue what to do with them. Ask yourself, what would I use a bot for? Keep in mind the dark side of bots. By running a bot down your are slowing down everyone especailly yourself. How is this possible? When you run a bot, it is just a user. The more users that are connected to IRC servers, the slower things get because more information has to be transferred. On your end, you now have two processes running on your machine. The more processes you have running the slower things will be, not only for you but everyone else. So what are you trying to say? Think about wether you need to run a bot or not. Will it be useful to you and everyone else. Clean up failed attempts at running bots. The best way to do this is include a die command in your bot. A simple example for a die command on a bot named Diebot: on msg "Diebot die" /quit Dead! So all you have to do is /msg Diebot die, and the bot will signoff so you won't have to kill the process. How do I clean up my old bots? From your prompt find the process id (PID). From unix try ps -x or ps -af|grep irc. Once you find the PID do a kill -9 PID. For example: kill -9 1234 Is that it? Yup, hopefully by now you understand what a bot is and how it works. Remember this was just an intro to bots. Where can I get more info? Reading alt.irc.bots is a good place to find information. Reading through other peoples bots code and scripts is a good way to learn. The Superpak script is an excellent example and is available via ftp from sci.dixie.edu in /pub/irc/scripts. There is a vms script there that is also very good (and is a lot more basic for those of you that do not have a good grasp of ircII scripting).