-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcall.py
72 lines (58 loc) · 2.14 KB
/
call.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
##############################################
## last updated: Dec, 12 2008
##
## Charles Bock - Cbock at ASU dot EDU
##
## Tested with Skype4Py version 0.9.28.2 and Skype verson 3.5.0.214
##############################################
import sys
import Skype4Py
# 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]);
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'
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("+1"+str(CmdLine))
break
if not Found:
print 'Call target not found in contact list Attempting direct Call'
skype.PlaceCall(CmdLine)
# Loop until CallStatus gets one of "call terminated" values in OnCall handler
while not CallStatus in CallIsFinished:
pass