What I want to do is build a simple bot which sends me a set of information stored in database to my messanger chat window [Chatting services are gTalk, Yahoo and other commonly used chating products] Also, it should be capable of accepting few predefined commands and replying them.
Is there any opensource code available for this?
Look up AIML (Artificial Intelligence Markup Language), it's been around a number of years and it's pretty well defined and flexible for simple stuff. You can also do pretty sophisticated stuff with all sorts of recursive templates and the results are pretty decent (as far as dumb bots go).
There's a bunch of open sdk projects that use this markup language, that will take care of matching your input patterns to a given reply stored in the xml files you'll have to configure with templates.
I worked on a messenger bot a few years back in Java using AIML for storing patterns (there are plenty APIs if you follow those links above) and used the incesoft msn bot platform. Worked out just fine.
Hope it helps.
For something that tries to be a bit more sophisticated, you can look at the NLTK Natural Language Toolkit:
Based on Python and intended for education, but there's quite a bit of documentation and at least a couple of books (one is open source).
As far as the different chat networks go, you may want to check out Pidgin ( http://www.pidgin.im/download/source/ ) , which is a cross-platform GPLed chat client written in C & GTK+ which works with all the major chat networks.
you may consider to find some resource of AI there is a very good example of chatbot available try to google verbot which is built with .NET library
We made one pretty easy to extend in python, it works with XMPP / gtalk : http://gbin.github.com/err/
To give you an idea the minimum hello world is as follow:
from errbot.botplugin import BotPlugin
from errbot.jabberbot import botcmd
class HelloWorld(BotPlugin):
@botcmd
def hello(self, mess, args): # the chatbot will then respond to the command !hello
""" this command says hello """ # this will be the result of !help hello
return 'Hello World !' # this will be the answer
I have been using Github's hubot for this purpose. My bot, when asked to tell a joke, tells a joke. (Of course I also have one that I can ask what I am supposed to be working on, and it looks up my worklist.)
GoGoBot> tell a joke about me
GoGoBot> a joke about Shell... Let me think about it...
GoGoBot>
I heard a funny one the other day:
Chuck Norris doesn't look both ways before he crosses the street...
he just roundhouses any cars that get too close.
The bot runs on NodeJS. The api takes a regex and a callback like
robot.hear /tell a joke/i, (msg) -> msg.send 'I heard a funny joke...'
module.exports = (robot) ->
robot.hear /tell (?:a|something) (?:joke|funny)(?: about ([a-z.]+))?/i, (msg) ->
subject = getSubject msg.match[1], msg.message.user.name
msg.send 'a joke about ' + subject + '... Let me think about it...' if subject.length
tellJoke = ->
getJoke subject, (err, text) ->
msg.send "Cannot compute. #{robot.name} is about to die.\r\n#{err}".replace(/e/ig, '3') if err?
msg.send "I heard a funny one the other day:\r\n#{text}" unless err?
setTimeout tellJoke, 5000 * Math.random()
It was pretty easy to learn since I am already familiar with NodeJS and coffee-script. I wrote the two bots I mentioned in a few hours today.
IMified might be an easy way to get started, it lets you build IM chat bots with server-side web development tools to receive messages, and just by making HTTP requests to send messages or request statuses.
http://www.imified.com/hosting/
IMified's API-based solution for creating and hosting instant messaging applications removes the complexity and provides a simple solution for building and deploying IM applications on multiple public IM networks using one API.
API docs here: http://www.imified.com/developers/api
An application connected to the IMified platform is in its simplest form a dynamic web page that resides on any HTTP server and listens for incoming messages then outputs a response. You specify an endpoint URL in your bots' settings. Developers may also "push" messages to users, as well as request a users presence via a REST api call to IMified's server.
来源:https://stackoverflow.com/questions/4129725/simple-chat-bot-projects