Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm a nub programmer, using python, and my current project is a chatbot for an irc channel I reside in. I wish to make it capable of keeping conversations organized, primarily between its self and one other person.

Right now, I'm creating a conversation object when the bot is initially addressed. The object has the attributed of peer (the other conversation member), topic (the basic topic of the conversation), log (a log of past messages to and from the peer), lastsent (super-simplified forms of the most recent 10 messages sent to the channel by the bot), and lastrecv (the last 10 messages received sent to the channel by the peer, also super-simplified). As messages are received, the bot checks the topic and runs through a list of expected replies. If one is matched, the bot chooses a response and send it to the channel. It then updates the topic if needed and the bot's conversation dictionary.

The bot has a conversation dictionary list, the key is the user's nickname, and the definition is the conversation object.

I feel this is unnecessarily excessive. I was wondering what some other approaches to keeping track of conversations were. Are there any simpler, easier approaches?

share|improve this question
It is not much clear to me from your question what you are using to build the bot. It looks like you have already built it and now want to determine how to keep track of conversations. Well if that is the case then you have already done the hard part... What is keeping you from saving the peer name, timestamp and text? –  Yasir Jul 9 '11 at 6:15
@ Yasir: I'm using python 2.6 and the Twisted irc module. I have built the bot and am trying to determine how to keep track of conversations, like you said. I do save the peer name and text. As for timestamp, I only save the time of the most recent message and that is overwritten each time a new message is received. –  xBlink Jul 9 '11 at 6:23
Ok, so what is the purpose of saving conversations? This is possibly the biggest factor to determine what to save. –  Yasir Jul 9 '11 at 6:37
More than saving the conversation, I want the program to keep track of them and respond to them. For example, without the conversation objects, the bot would respond to anything you tell it. You could jump from talking about dogs to telling it hello and it would not care, it would just respond. I want conversation objects to allow the program to keep track of who it's talking to, and what it's talking about. My question is really: what are some approaches to allow the program to maintain conversations and seem a little more human? –  xBlink Jul 9 '11 at 6:45
Maybe you should change your approach. Try thinking about how do you reply if someone ask you something rather than how a piece of software should reply. You need a topic (if this is an IRC channel, maybe you dont need this) and a question in orden to make a decision on what to respond. –  guiman Dec 6 '11 at 1:36
add comment

1 Answer

I happen to be working on a chatbot, too. Like you, my code was getting complicated way to fast. Then I found this tutorial: http://ai-programming.com/bot_tutorial.htm. They have a text file with each line marking it as either a keyphrase or a response. It is also a good idea to factor in sentence positioning and template responses.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.