Here is a complete solution using python and pymsn Telepathy Wiki - Pymsn
The author wrote the script based on the sample script provided in the lib:
and the syntax is justCode:#!/usr/bin/env python #Author: Alejandro Endo #Date: 18/01/08 #Description: Sends an online or offline message to an MSN account #Libraries: Using pymsn, available here http://telepathy.freedesktop.org/wiki/Pymsn ####Imports#### import pymsn import pymsn.event import sys import logging import gobject logging.basicConfig(level=logging.ERROR) ####Constants#### SENDER_ACCOUNT = "XXXX@hotmail.com" SENDER_PASSWORD = "XXXX" RECEIVER_ACCOUNT = "XXX@hotmail.com" MESSENGER_NICK = "Roboto" RECEIVER_NICK = "Hilikus" ###Classes#### class ClientEvents(pymsn.event.ClientEventInterface): def on_client_state_changed(self, state): if state == pymsn.event.ClientState.CLOSED: self._client.quit() elif state == pymsn.event.ClientState.OPEN: self._client.profile.display_name = MESSENGER_NICK self._client.profile.presence = pymsn.Presence.ONLINE self._client.profile.current_media = ("I listen to", "Master " + RECEIVER_NICK ) gobject.timeout_add(500, self._client.start_conversation) def on_client_error(self, error_type, error): print "ERROR :", error_type, " ->", error class WaitAndSend(pymsn.event.ConversationEventInterface): def on_conversation_user_joined(self, contact): self._client.send_text_message(pymsn.ConversationMessage(' '.join(sys.argv[1:]))) class Client(pymsn.Client): def __init__(self, account, quit, http_mode=False): server = ('messenger.hotmail.com', 1863) self.quit = quit self.account = account if http_mode: from pymsn.transport import HTTPPollConnection pymsn.Client.__init__(self, server, get_proxies(), HTTPPollConnection) else: pymsn.Client.__init__(self, server) self._event_handler = ClientEvents(self) gobject.idle_add(self._connect) def _connect(self): self.login(*self.account) return True def start_conversation(self): receiverContact = self.address_book.contacts.search_by_account(RECEIVER_ACCOUNT) if len(receiverContact) == 0: print RECEIVER_NICK + " not found in contact list" return True else: if receiverContact[0].presence == pymsn.Presence.OFFLINE: self.oim_box.send_message(receiverContact[0], ' '.join(sys.argv[1:])) else: self.conv = pymsn.Conversation(self, receiverContact) self._convo_events = WaitAndSend(self.conv) gobject.timeout_add(4000, self.quit) return False def main(): import sys import getpass import signal import pymsn server = ('messenger.hotmail.com', 1863) account = SENDER_ACCOUNT passwd = SENDER_PASSWORD if "--http" in sys.argv: http_mode = True sys.argv.remove('--http') else: http_mode = False mainloop = gobject.MainLoop(is_running=True) def quit(): mainloop.quit() def sigterm_cb(): gobject.idle_add(quit) signal.signal(signal.SIGTERM, sigterm_cb) Client((account, passwd), quit, http_mode) while mainloop.is_running(): try: mainloop.run() except KeyboardInterrupt: quit() if __name__ == '__main__': main()
Code:msnNotifier "hello, this is a message"


LinkBack URL
About LinkBacks




Reply With Quote
