views:

118

answers:

2

ok I am well aware there are many other questions about this, but I have been searching and have yet to find a solid proper answer that doesnt revolve around jabber or something worse. (no offense to jabber users, just I don't want all the extras that come with it)

I currently have msnp and twisted.words, I simply want to send and receive messages, have read many examples that have failed to work, and msnp is poorly documented.

My preference is msnp as it requires much less code, I'm not looking for something complicated.

Using this code I can login, and view my friends that are online (can't send them messages though.):

import msnp
import time, threading



msn = msnp.Session()
msn.login('[email protected]', 'XXXXXX')
msn.sync_friend_list()

class MSN_Thread(threading.Thread):
    def run(self):
        msn.start_chat("[email protected]") #this does not work
        while True:
            msn.process()
            time.sleep(1)



start_msn = MSN_Thread()
start_msn.start()

I hope I have been clear enough, its pretty late and my head is not in a clear state after all this msn frustration.

edit: since it seems msnp is extremely outdated could anyone recommend with simple examples on how I could achieve this? Don't need anything fancy that requires other accounts.

A: 

You are using a library abandoned in 2004 so i'm not sure if msnp could still be used to talk on MSN.
Anyway i would try with:

while True:
     msn.process(chats = True)
     time.sleep(1)

using the contact id and not the email address.

contacts = msn.friend_list.get_friends()
contact_id = contacts.get_passport_id() 

Your code just start the chat without sending anything; you need to add the code to send message.
Have a look to send_message method in this tutorial.

systempuntoout
not sure what thats supposed to do, has not allowed me to send a message to another account yet.
code_by_night
@code try to use the name and not the email.
systempuntoout
@Code according to the tutorial, the chats = True option tells msn to process commands for all currently active chat sessions.
systempuntoout
@system not quite sure what you mean there, but I changed [msn.start_chat("Joe")], now I'm getting a "global name 'Error' is not defined" I guess thats something, care to elaborate?edit: and yes, I did use the name of the contact "Joe" instead of the email address
code_by_night
@system, is this what you mean?contact_id = friend.get_passport_id(), contact_id = contacts.get_passport_id()I keep getting errors on the last one. I'm putting them in the while loop if it means anything.
code_by_night
@code corrected
systempuntoout
@system is any of this working for you? my account logs in but nothing else happens. edit: also contacts is an empty list, contact_id shows up as nothing
code_by_night
@code Are you aware that you are not sending any text message with your code?
systempuntoout
@system oh dear, told you it was late (only just occured to me). using help(msn.start_chat) there seems to be no way of adding a message to the code, or am I not looking hard enough? Just tested again and surely enough it won't take anymore arguments.
code_by_night
I have already tried that code, but for some reason it doesnt do anything, not even log in. I did change the login details too.
code_by_night
A: 

It looks like papyon is a maintained fork of the pymsn library, and is currently used by telepathy-butterfly and amsn2.

papyon is an MSN client library, that tries to abstract the MSN protocol gory details. It is a fork of the unmaintained pymsn MSN library. papyon uses the GLib main event loop to process the network events in an asynchronous manner.

Matt Austin