MSN Gateway using PYNET
msnp.py is an implementation of the MSN instant messaging protocol in the Python programming language. This pure Python package makes it extremely easy, quick, and efficient to build applications that need to interact with the MSN messaging service.
MY CODE:
import msnp
import time
class MsnListener(msnp.SessionCallbacks):
def state_changed(self, state):
if state == msnp.States.ONLINE:
print 'online kn ^_^!'
msn = msnp.Session(MsnListener())
msn.login('johnpaul86@hotmail.com', 'jpmama')
while True:
msn.process()
time.sleep(1)
IM - Instant Messaging
#using msnp.py - msn protocol
import msnp
import time
class MsnChatListener(msnp.ChatCallbacks):
def message_received(self, passport_id, display_name, text, charset):
print '%s: %s' % (passport_id, text)
self.chat.send_message(text, charset)
class MsnListener(msnp.SessionCallbacks):
def chat_started(self, chat):
callbacks = MsnChatListener()
chat.callbacks = callbacks
callbacks.chat = chat
msn = msnp.Session(MsnListener())
msn.login('johnpaul86@hotmail.com', 'jpmama')
while True:
msn.process(chats = True)
time.sleep(1)
No comments:
Post a Comment