Recently I needed to write a small utility for Skype. Python seemed as a good start for this purpose as the language is easy and flexible and it has a Skype4Py module with all the necessary APIs. The installation is straightforward. First off, go to the download page and get the latest version. Then go to the folder you downloaded it into and unpack the archive:
tar xzvf Skype4Py-1.0.31.0.tar.gz
Go to the folder with the source and install the module:
cd Skype4Py-1.0.31.0
sudo python setup.py install
Now when everything is installed, you can proceed to the code. There are not much examples of the code in the Internet, but if you know python, then the process is very simple. The project page has extensive documentation on all the classes and methods, and is very helpful in using this module. To demonstrate how it all works, I wrote a small and not very useful program, which however serves its purpose:
import sys
import Skype4Py
# attach our program to the Skype
def OnAttach(status):
print 'API attachment status: ' + skype.Convert.AttachmentStatusToText(status)
if status == Skype4Py.apiAttachAvailable:
skype.Attach()
# create Skype object
skype = Skype4Py.Skype()
skype.OnAttachmentStatus = OnAttach
if not skype.Client.IsRunning:
print 'Starting Skype..'
skype.Client.Start()
# get the name of Skype contact from the command line and create an object uprofile
uname = sys.argv[1]
uprofile = skype.User(Username=uname)
# now we can use all the methods from this object (see the documentations for "IUser" class for all available methods)
# print the full name of a person
print 'profile: ' + uprofile.FullName
# open chat with uname
message = 'From cmd: ' + sys.argv[2]
uchat = skype.CreateChatWith(uname)
uchat.SendMessage(message)
print 'message sent: ' + message
sys.exit
The main Skype interface is Skype4Py.Skype, from there you start the chat, get the user profiles, place calls and do all other things.
To run this program, use this command, where skypedummy.py is the name of your program, “i.am” is the skype name of the contact, and in the quotation marks is the message you are sending to him:
python skypedummy.py i.am "Greetings from my first skype app"