~mike6d696b65/cit200/Cit200

« back to all changes in this revision

Viewing changes to python/contacts/contact.py

  • Committer: mike6d696b65 at gmail
  • Date: 2011-03-23 03:05:47 UTC
  • Revision ID: mike6d696b65@gmail.com-20110323030547-kenpipgx3n3lz75u
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 #!/usr/bin/python
 
2
# ----------------------------------------------------------------------------------------------------
 
3
#  Python / Skype4Py example that sets user's online status to Do Not Disturb
 
4
#
 
5
 
 
6
import sys
 
7
import Skype4Py
 
8
 
 
9
# ----------------------------------------------------------------------------------------------------
 
10
# Fired on attachment status change. If attachment to API is successful,
 
11
# this function sets skype.CurrentUserStatus to 'DND'.
 
12
 
 
13
def OnAttach(status):
 
14
        print 'API attachment status: ' + skype.Convert.AttachmentStatusToText(status)
 
15
 
 
16
        if status == Skype4Py.apiAttachAvailable:
 
17
                skype.Attach()
 
18
 
 
19
        if status == Skype4Py.apiAttachSuccess:
 
20
                print 'Reading Skype\'s contact info'
 
21
                #for user in skype.Friends:
 
22
                #    print(user.Handle)
 
23
                tmp = tuple(sorted(skype.Friends, key=lambda friend: friend.FullName))
 
24
                friends = tuple(sorted(tmp, key=lambda friend: friend.OnlineStatus, reverse=True))
 
25
                arg = int(sys.argv[1])
 
26
                if arg == 0:
 
27
                        print(friends[arg].Handle)
 
28
                        print(friends[arg].FullName)
 
29
                        print(friends[arg].OnlineStatus)
 
30
                        print(friends[arg].Language)
 
31
                        print(friends[arg].Birthday)
 
32
                        print(friends[arg].Sex)
 
33
                        print(friends[arg].PhoneHome)
 
34
                        print(friends[arg].PhoneMobile)
 
35
                        print(friends[arg].PhoneOffice)
 
36
                        print(friends[1].Handle)
 
37
                        print(friends[1].FullName)
 
38
                        print(friends[1].OnlineStatus)
 
39
                        print(friends[1].Language)
 
40
                        print(friends[1].Birthday)
 
41
                        print(friends[1].Sex)
 
42
                        print(friends[1].PhoneHome)
 
43
                        print(friends[1].PhoneMobile)
 
44
                        print(friends[1].PhoneOffice)
 
45
                else:
 
46
                        print(friends[arg].Handle)
 
47
                        print(friends[arg].FullName)
 
48
                        print(friends[arg].OnlineStatus)
 
49
                        print(friends[arg].Language)
 
50
                        print(friends[arg].Birthday)
 
51
                        print(friends[arg].Sex)
 
52
                        print(friends[arg].PhoneHome)
 
53
                        print(friends[arg].PhoneMobile)
 
54
                        print(friends[arg].PhoneOffice)
 
55
                        print(sys.argv[1])
 
56
                        print(friends[arg].Aliases)
 
57
        
 
58
 
 
59
# ----------------------------------------------------------------------------------------------------
 
60
# Fired on user's online status change. Prints out new status.
 
61
 
 
62
#def OnUserStatus(status):
 
63
#    print 'User status has changed to ' + status
 
64
 
 
65
 
 
66
# ----------------------------------------------------------------------------------------------------
 
67
# Creating instance of Skype object, assigning handler functions and attaching to Skype.
 
68
 
 
69
skype = Skype4Py.Skype()
 
70
skype.OnAttachmentStatus = OnAttach
 
71
#skype.OnUserStatus = OnUserStatus
 
72
 
 
73
print 'Connecting to Skype..'
 
74
skype.Attach()
 
75
 
 
76
# ----------------------------------------------------------------------------------------------------
 
77
# Looping until user types 'exit'
 
78
Cmd = '';
 
79
#while not Cmd == 'exit':
 
80
#    Cmd = raw_input('');