• Python Noob-- I need help.
    0 replies, posted
Okay, I need help with this python script I am trying to modify. It is a script for the Skype API Using Skype4Py. The script in it's current state just calls the specified user when it is run. I need help modifying it to always be checking if I am in a call, and if I am not it calls the specified person. Ex, I am in a call, but it drops, and skype can't get it back, so it keeps trying to call the person over and over until it gets it. Or, if I am not in a call, it calls them when the script is run, and if I hang up it calls them again. Here is the code I have already. [code] #!python # --------------------------------------------------------------------------------------------- # Python / Skype4Py example that takes a skypename from command line parameter, # checks if that skypename is in contact list and if yes then starts a call to that skypename. # # Tested with Skype4Py version 0.9.28.2 and Skype verson 3.5.0.214 import sys import Skype4Py import time # This variable will get its actual value in OnCall handler CallStatus = 0 # Here we define a set of call statuses that indicate a call has been either aborted or finished CallIsFinished = set ([Skype4Py.clsFailed, Skype4Py.clsFinished, Skype4Py.clsMissed, Skype4Py.clsRefused, Skype4Py.clsBusy, Skype4Py.clsCancelled]); CallIsActive = set ([Skype4Py.clsInProgress]); while not CallStatus in CallIsActive: time.sleep(5) def AttachmentStatusText(status): return skype.Convert.AttachmentStatusToText(status) def CallStatusText(status): return skype.Convert.CallStatusToText(status) # This handler is fired when status of Call object has changed def OnCall(call, status): global CallStatus CallStatus = status print 'Call status: ' + CallStatusText(status) # This handler is fired when Skype attatchment status changes def OnAttach(status): print 'API attachment status: ' + AttachmentStatusText(status) if status == Skype4Py.apiAttachAvailable: skype.Attach() # Let's see if we were started with a command line parameter.. try: CmdLine = sys.argv[1] except: print 'Missing command line parameter: No Name!' sys.exit() # Creating Skype object and assigning event handlers.. skype = Skype4Py.Skype() skype.OnAttachmentStatus = OnAttach skype.OnCallStatus = OnCall # Starting Skype if it's not running already.. if not skype.Client.IsRunning: print 'Starting Skype..' skype.Client.Start() # Attatching to Skype.. print 'Connecting to Skype..' skype.Attach() # Checking if what we got from command line parameter is present in our contact list Found = False for F in skype.Friends: if F.Handle == CmdLine: Found = True print 'Calling ' + F.Handle + '..' skype.PlaceCall(CmdLine) break if not Found: print 'Call target not found in contact list' sys.exit() # Loop until CallStatus gets one of "call terminated" values in OnCall handler while not CallStatus in CallIsFinished: pass [/code] Thanks for your help.
Sorry, you need to Log In to post a reply to this thread.