# ---------------------------------------------------------------------------------------------------- # Python / Skype4Py example that prints out chat messages # # Tested with Skype4Py version 0.9.28.5 and Skype verson 3.8.0.96 import sys import os import time import Skype4Py import random def ndsSay(ndsWords): ndsIn = str(ndsWords) zcmd='espeak "'+ndsTalk+'"' print zcmd f=os.popen(zcmd) f.close() ndsWords="" ndsTalk="" zcmd='' ndsMonkey='' # ---------------------------------------------------------------------------------------------------- # Fired on attachment status change. Here used to re-attach this script to Skype in case attachment is lost. Just in #case. def OnAttach(status): print 'API attachment status: ' + skype.Convert.AttachmentStatusToText(status) if status == Skype4Py.apiAttachAvailable: skype.Attach() if status == Skype4Py.apiAttachSuccess: print('***************************************') # ---------------------------------------------------------------------------------------------------- # Fired on chat message status change. # Statuses can be: 'UNKNOWN' 'SENDING' 'SENT' 'RECEIVED' 'READ' def OnMessageStatus(Message, Status): if Status == 'RECEIVED': print(Message.FromDisplayName + ': ' + Message.Body) ndsSay(Message.FromDisplayName) ndsSay(Message.Body) if Status == 'READ': ndsMonkey = "todo" print(Message.FromDisplayName + ': ' + Message.Body) ndsSay(Message.FromDisplayName) ndsSay(Message.Body) if Status == 'SENT': print('Myself ' + Message.Body) # ---------------------------------------------------------------------------------------------------- # Creating instance of Skype object, assigning handler functions and attaching to Skype. skype = Skype4Py.Skype() skype.OnAttachmentStatus = OnAttach skype.OnMessageStatus = OnMessageStatus print('***************************************') print 'Connecting to Skype..' skype.Attach() # ---------------------------------------------------------------------------------------------------- # Looping until user types 'exit' Cmd = '' while not Cmd == 'exit': Cmd = raw_input('')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question