Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'msnp.py-0.4.1/msnp';
- username = 'your@email.com'
- password = 'yourpassword'
- class ChatEvents(msnp.ChatCallbacks):
- def message_received(self, email, name, text, charset):
- print email, '(' + name + ')', 'has sent you "', text, '"with charset', charset;
- self.chat.send_message (text);
- class SessionEvents(msnp.SessionCallbacks):
- def ping(self):
- print "Pinged by server";
- def chat_started(self, chat):
- new_callbacks = ChatEvents();
- chat.callbacks = new_callbacks;
- new_callbacks.chat = chat;
- print "New chat started with", repr(chat.initial_members);
- def friend_added(self, list_, passport_id, display_name, group_id = -1):
- if (list_ == msnp.Lists.REVERSE):
- print "Added to", passport_id, '(' + display_name + ')','\'s list';
- #Add them back automatically
- print "Logging in...";
- msn = msnp.Session(SessionEvents());
- msn.login (username, password, msnp.States.ONLINE);
- print "Syncing friends list, making you visible to friends...";
- msn.sync_friend_list(-1);
- print "Logged in! 'Ctl-C' to exit.";
- while(1):
- try:
- msn.process(True);
- except Exception, x:
- print("Error: %s" % (x));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement