Home      Updates      RSS Feed      About      Code      Contact

  IRC Bots September 26 2011  5:22 PM EST

What have I been working on since last time? Well, currently I'm preoccupied with IRC bots. I had always planned to get fyodor up and running on IRC (in addition to email and text messages). Since Phong, the previous bot in the ACM's room (#uakroncs on slashnet) is no longer there, I thought I would work on getting something at least marginally functional to play around with. Plus, this way I would be able to hack the source much easier, as I would be writing it in a language I actually know and not python.

As usual I've started projects in a few languages :D First, there was jbotd who is written in D. I got through the major work of figuring out sockets and getting him to connect. Then, I wanted to let him spew nonsense based on Markov chains generated on all the chatter in the channel. This proved to be more difficult than I initially hoped, as the language level associative arrays only support keys that are strings (immutable char[]). To be able to generalize this to multiple orders, it would be very difficult, and I simply have not yet had the time to dive in and get it done.

The second project, jbotc has now become more mature than jbotd. This one is written in C. A lot more time has been put into the base of jbotc, including things such as comments (who needs those?) and a simple upgrade framework. jbotc is split into two parts: conbot and jbot. jbot reads IRC messages on stdin, and outputs IRC commands on stdout. Very easy to test him, and he doesn't have to worry about sockets, pipes, or any complicated IO schemes. Then, there is conbot. His job is to maintain the connection to the IRC server. In addition to this, he handles forking himself and exec'ing jbot as a new image. This way, I can tell jbot to restart, and conbot can stay connected and simply restart jbot. When jbot is started through conbot, it sets up pipes to and from jbot. conbot just dumps unparsed messages from the server into jbot, and shoots jbot's output back out. All in all, conbot has three threads and jbot is run as a separate process. Fun! :D

Now, I have not exactly gotten jbot to use Markov chains yet, but it is on the way. I am still deciding on the exact data structure to use, as I will want to be able to write and read these from a file to keep a persistent AI. I have to think of space, both memory and disk, while I'm at it. So exciting :D Now, since jbotc is in C, it would be very difficult to be tremendously slower than python (even with the massive amounts more of time that have been put into Supybot) -- at least I hope.

There is already a lot planned for jbot. One of the more pressing things is to handle infinite loops in responses between two instances. That is very pressing, in fact. I'll probably do something simple for now, but it will still take some code to do. In addition, conbot needs to be made more robust. Right now it doesn't even try to recover from errors, and the only one it handles currently is the nick being in use. Guess I'll need to read more of the IRC protocol :)

 

My name is Jeff Chapman; You can reach me at: [email protected]