As part of my adventures on IRC, I wrote a bot called dobodob. By reading the IRC RFCs, I was able to implement a simple python client for IRC that now acts as a personal bot.
The goal with dobodob was to write a bot that almost seems human - the idea is that a skilled operator of dobodob will be able to formulate sentences that look like normal human conversation and dobodob will answer them seamlessly.
dobodob: can you pick a hard problem from hackerrank for me? or
dobodob: please solve 5x + 3 = 2. The main idea is that there are stopwords
that are automatically stripped from the command, so an operator can phrase the
same command in many different ways that seem more natural than the typical way
we talk to bots.
To make dobodob seem more a human, small delays are added before she responds - she also refuses to say the same thing twice within a set amount of time.
I’ve managed to fool a handful of people into thinking dobodob is a person, which makes me feel like the project was a success.
Some of the more useful commands dobodob supported (aside from her general banter) are:
- picking problems from hackerrank and leetcode
- using wolfram alpha to solve equations
- looking up sequences on OEIS
dobodob also has a feature where she observes the conversation in a channel and when someone makes a declarative statement, like “I am hungry”, dobodob keeps track of that fact and can later answer questions about people. The challenge here was to correctly rephrase various declarations into the proper form when dobodob would repeat them. For example: “I am hungry” has to be turned into “oky is hungry” and “I wish I had food” has to be turned into “oky wishes they had food”, etc.
I eventually turned this feature off, because people didn’t appreciate the bot making observations about them - something about an invasion of privacy. Of course, IRC is already compromised, so any conversation going on there is likely already being spied on, but we all like to believe that we are safe.
Outside of implementing the basic portions of IRC protocol and a few interactive commands, my favorite part of dobodob is that she’s able to reload her code on the fly while staying connected to IRC. Python has a method for reloading modules, but some small amount of work needed to be done to be able to connect a socket to IRC, then hand that socket forward from one instance of a class to the next when re-instantiating it.