Tuesday, July 8, 2008

Python fun project : MSN CHAT bot

I downloaded MSN-lib 3.6 from sourceforge and soon the naughty idea of linking this with Eliza
the therapist (joe, jeff , jez version of Eliza in python) cropped up almost instantly in my head.
So using a skeleton code of using MSN-lib i picked up from some forum, i did 1+ 1 = 2.

To make it realisic, i provide the "first msg" and the victim input before the bot takes full auto drive.

(All credits due to the original author and contributor to msnlib, eliza and related sources)

I must say i had a great time laughing over the chat logs as my friends and peers communicated with my chatbot. I made the program to log to some hardcoded directory of c:\msnbot since some sample codes is logging to some unix paths.

Well, if u need a break and a laugh, here is the chatbot and continue reading to find out how to configure it :-

Open the file : marbot.py, edit the values below and enter ur hotmail login and password.

m.email = "xxxx"
m.pwd = "xxxx"

Also change the name and nick to ur own :-

m.change_nick("-M- The future")

Ok, done now you are ready to go :-

python marbot.py

or just :

marbot.py

After running for a while it will ask 2 lines of input , the first line is the email id of the "victim" you intend to start a conversation with, the 2nd line is the first message you want to send to this person.

From then on, just watch and laugh as your friend communicate with Eliza. The logs are found in c:\msnbot (create this directory or unzip the files below to this directory)

Download the fun bot here

12 comments:

  1. Really nice project here ... icant seem to get it to work under linux.
    take a look.
    This is when i spoke to the bot after it didnt say anything to me.



    the@victim.com
    <<< hey


    Traceback (most recent call last):
    File "marbot.py", line 324, in TAGmoduleTAG
    m.read(i)
    File "/home/mtuserdir/Desktop/dl/marbot.msnlib-3.6.zip_FILES/msnlib.py", line 671, in read
    self.cb.msg(self, type, params, msg, nd)
    File "marbot.py", line 159, in cb_msg
    log_msg(email, 'in', string.join(lines[eoh:], '\n'))
    File "marbot.py", line 218, in log_msg
    fd = open(file, 'a')
    IOError: [Errno 2] No such file or directory: '/msnbot/the@victim.com'

    I had to remove tags to post = TAG

    Be cool if you could show me how to fix this

    ReplyDelete
  2. What is the license of this project?

    ReplyDelete
  3. Hi Fisix,

    You need to create "msnbot" directory at your linux , eg /msnbot. Give it sufficient rights for write also.

    -have fun, btw are u guys from malaysia? pls register urself at www.python.my

    ReplyDelete
  4. Kun xi,

    the license is whatever as maintained by msnlib and eliza, its free but u need to maintain the credit info, and u can add "codemagnet" to it, but basically, feel free to use it.

    ReplyDelete
  5. i'd like to log both the bot and the victims conversation. how can this be done?

    ReplyDelete
  6. Could someone please reupload this?

    ReplyDelete
  7. Ok re-uploaded. have fun. Create a folder eg, c:\msnbot and unzip to there. It will need the folder /msnbot, which in windows is c:\msnbot, or linux /msnbot.

    ReplyDelete
  8. Thanks, appreciated :)

    ReplyDelete
  9. PASSPORT begin
    SSL Connect to https://login.live.com/login2.srf
    SSL GET
    SSL Response 401
    /home/adm/msnbot/msnlib.py:574: DeprecationWarning: raising a string exception is deprecated
    raise 'AuthError', [911, 'SSL Auth failed']
    Traceback (most recent call last):
    File "marbot.py", line 55, in module
    m.login()
    File "/home/adm/msnbot/msnlib.py", line 503, in login
    passportid = self.passport_auth(hash)
    File "/home/adm/msnbot/msnlib.py", line 574, in passport_auth
    raise 'AuthError', [911, 'SSL Auth failed']
    AuthError: [911, 'SSL Auth failed']

    Any ideia ?

    ReplyDelete
  10. Jen140,
    Most likely u forgot to use a valid name/pass located at the top of the source code.
    Replace the below with ur MSN login/pass.

    m.email = "xxxx"
    m.pwd = "xxxx"

    ReplyDelete
  11. How do you make it so, it will respond when the victim messages you first. because if they try to message first without you sending them a message nothing happens.

    ReplyDelete
  12. this is my take on a very minimal chatbot in Python, no msging functionality just the basic engine to generate responses...

    http://pythonism.wordpress.com/2010/04/18/a-simple-chatbot-in-python/

    ReplyDelete