Hello Friends,<br><br>Do you think it is cool if you are able to handover the overhead of chatting with friends to an Artificial intelligence program called Eliza .. For those who don't know Eliza, it is a computer program by Joseph Weizenbaum which simulates a therapist. <br><br>Now let's do that using Python. To use the Gchat which uses XMPP protocol, we need to install a python module called xmpppy . It is available at http://xmpppy.sourceforge.net/. The standard 'python setup.py install ' will perform the installation of module for us .<br><br>This program has two files<br>1) eliza.py <br>2) eliza_googletalk.py<br><br><br>Now the eliza.py program which sends the chat string send by our friends to the Eliza program and returns the reply of Eliza AI program.<br><br>####################################################################<br># This program will talk with eliza, the psychiatrist AI program&nbsp;&nbsp; #<br># By Maxin B. John
 &lt;maxinbjohn@gmail.com&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #<br>####################################################################<br><br>import httplib<br>import urllib<br><br>#Function that POSTS the string to eliza website and formats the reply<br># my_dialog is the string that we POST to the www-ai.ijs.si website<br># obtains the reply from eliza scripts and prints it on the screen<br><br>def eliza(my_dialog):<br>&nbsp;&nbsp; &nbsp;params = urllib.urlencode({'Entry1': my_dialog})<br>&nbsp;&nbsp; &nbsp;headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}<br>&nbsp;&nbsp; &nbsp;conn = httplib.HTTPConnection("www-ai.ijs.si")<br>&nbsp;&nbsp; &nbsp;conn.request("POST", "/eliza-cgi-bin/eliza_script", params, headers)<br>&nbsp;&nbsp; &nbsp;response = conn.getresponse()<br>&nbsp;&nbsp; &nbsp;data = response.read()<br>&nbsp;&nbsp; &nbsp;reply_from_eliza=
 str(data.split('&lt;/strong&gt;')[2]).split('\n')[1]<br>&nbsp;&nbsp; &nbsp;return "%s\r\n" % (reply_from_eliza,)<br>&nbsp;&nbsp; &nbsp;conn.close()<br><br># invoking the eliza function to test it's functionality in pythonic way<br>if __name__== '__main__':<br>&nbsp;&nbsp; &nbsp;str =eliza('I am maxin')<br>&nbsp;&nbsp; &nbsp;print str<br>############################################################<br><br>Now the main part of the program ... eliza_googletalk.py<br><br><br>##################################################################################<br># &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;You &lt;-&gt; Eliza Google chat&nbsp; program&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br># What:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br>#&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br># This program will login as you in the google chat and will automagically reply #<br># to those who are 'thinking' that they are chatting with you using the eliza&nbsp;&nbsp;&nbsp; # <br># AI program.&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br># How:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br>#&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br># The google chat handling/reply part is done using the xmpppy
 python module&nbsp;&nbsp;&nbsp;&nbsp; #<br># Chats from your friends will be passed to the eliza program and the resulting&nbsp; #<br># output will be returned back to your friends as though you have typed it.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # <br># Who:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br># &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br># Maxin B. John &lt;maxinbjohn@gmail.com&gt; This code is small and self explanatory&nbsp;&nbsp; #<br># So I haven't added a single comment in this program.&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; #<br>##################################################################################<br><br>import
 xmpp<br>import time<br>from eliza import *<br><br>def messageCB(sess,mess):<br>&nbsp;&nbsp;&nbsp; nick=mess.getFrom().getResource()<br>&nbsp;&nbsp;&nbsp; text=mess.getBody()<br>&nbsp;&nbsp;&nbsp; reply = eliza(text)<br>&nbsp;&nbsp;&nbsp; sess.send(xmpp.Message(mess.getFrom(),reply))<br><br>def LoopyFn(conn):<br>&nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; conn.Process(1)<br>&nbsp;&nbsp;&nbsp; except KeyboardInterrupt: <br>&nbsp;&nbsp; &nbsp;return 0<br>&nbsp;&nbsp;&nbsp; return 1<br>&nbsp;&nbsp; &nbsp;<br>def main_process():<br>&nbsp;&nbsp; &nbsp;jid = xmpp.protocol.JID('maxinbjohn@gmail.com')<br>&nbsp;&nbsp; &nbsp;cl = xmpp.Client('gmail.com')<br>&nbsp;&nbsp; &nbsp;cl.connect(('talk.google.com',5223))<br>&nbsp;&nbsp; &nbsp;cl.RegisterHandler('message',messageCB)<br>&nbsp;&nbsp; &nbsp;cl.auth(jid.getNode(),'my_secret_password')<br>&nbsp;&nbsp; &nbsp;cl.sendInitPresence()<br>&nbsp;&nbsp; &nbsp;while LoopyFn(cl): <br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;pass<br>if __name__ == '__main__':<br>&nbsp;&nbsp; &nbsp;main_process()<br><br>###################################################################<br><br>Run this program as <br><br>python eliza_googletalk.py<br><br>Now let your friends to be confused :) <br><br><p>&#32;
      <hr size=1> Sent from <a href="http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=51949/*http://uk.docs.yahoo.com/mail/winter07.html">Yahoo!</a> &#45; a smarter inbox.