python skype

5
Query7 Home Request A Tutorial About Contact Interacting with Skype from Python using Skype4Py Posted on January 3, 2011 Skype4Py is a Python module that allows developers to programatically interact with the Skype client running on their computer. In this tutorial we will look at and use the Skype4Py module to create simple but useful scripts. Installation Skype4Py is a normal Python module and is listed in the Python package index (Pypi). To install it with setuptools enter the following in a command prompt. easy_install Skype4Py To install it with pip enter the following in a command prompt. pip install Skype4Py Getting Started Skype4Py interacts with the Skype client running on your desktop, it doesn’t talk directly to the Skype servers. For any of the scripts we cover in this tutorial to work the Skype application must be running and you need to be logged in. You can either start Skype yourself or use the following snippet to start it using Skype4Py. s = Skype4Py.Skype() if not s.Client.IsRunning: s.Client.Start() Before we can interact with the Skype client from Skype2Py, we need to connect Skype4Py to the instance of Skype running on your desktop. This is done using the Attach method. Interacting with Skype from Python using Skype4P... http://query7.com/interacting-with-skype-from-pyth... 1 de 5 28-02-2012 14:07

Upload: walter-angolar-da-silva

Post on 21-Apr-2015

232 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Python Skype

Query7HomeRequest A TutorialAboutContact

Interacting with Skype from Python usingSkype4Py

Posted on January 3, 2011

Skype4Py is a Python module that allows developers to programaticallyinteract with the Skype client running on their computer. In this tutorial wewill look at and use the Skype4Py module to create simple but useful scripts.

Installation

Skype4Py is a normal Python module and is listed in the Python package index(Pypi). To install it with setuptools enter the following in a command prompt.

easy_install Skype4Py

To install it with pip enter the following in a command prompt.

pip install Skype4Py

Getting Started

Skype4Py interacts with the Skype client running on your desktop, it doesn’ttalk directly to the Skype servers. For any of the scripts we cover in thistutorial to work the Skype application must be running and you need to belogged in. You can either start Skype yourself or use the following snippet tostart it using Skype4Py.

s = Skype4Py.Skype()

if not s.Client.IsRunning:s.Client.Start()

Before we can interact with the Skype client from Skype2Py, we need toconnect Skype4Py to the instance of Skype running on your desktop. This isdone using the Attach method.

Interacting with Skype from Python using Skype4P... http://query7.com/interacting-with-skype-from-pyth...

1 de 5 28-02-2012 14:07

Page 2: Python Skype

import Skype4Py

s = Skype4Py.Skype()s.Attach()

After executing this you need to check the Skype client on your desktop. Anotification similar to the one below will appear. This ensures that no virus or3rd party program can use your Skype account without your knowledge. Click‘Allow access’.

User Information

Skype4Py provides a User class which represents a user’s Skype account. Wecan access information such as the user’s full name, their Skype status andwhen they were last logged into Skype. To get the person who is currentlylogged into the Skype client’s information we need to use the CurrentUserclass.

import Skype4Pys = Skype4Py.Skype()s.Attach()

print 'Full Name: %s' % s.CurrentUser.FullNameprint 'Skype Status: %s' % s.CurrentUser.OnlineStatusprint 'Country: %s' % s.CurrentUser.Country

To access information about the current Skype user’s friends, we need to usethe Friends class. The snippet below iterates over all of the current Skypeuser’s friends and prints some information about them.

import Skype4Pys = Skype4Py.Skype()s.Attach()

for f in s.Friends:print 'Full Name: %s' % f.FullNameprint 'Skype Status: %s' % f.OnlineStatusprint 'Country: %s' % f.Country

Sending SMS Messages

Skype4Py can also be used to send SMS messages. Only Skype users who havecredit in their Skype account can send SMS. Be sure to check local SMS rateson the Skype website before using and never put this code in a loop without

Interacting with Skype from Python using Skype4P... http://query7.com/interacting-with-skype-from-pyth...

2 de 5 28-02-2012 14:07

Page 3: Python Skype

double checking it first. Make sure you include your country’s internationalprefix at the beginning of the number variable. After using this code my phonereceived the SMS 20 seconds later (NZ carrier).

import Skype4Pys = Skype4Py.Skype()s.Attach()

message = 'Hello SMS from Query7'number = '+641234567890'

m = s.CreateSms(Skype4Py.smsMessageTypeOutgoing, number)m.Body = message

m.Send()

What Else Can Skype4Py Do?

Download and play voice mail messagesTransfer files between Skype clientsInteract with Skype chat messages

Leave a Reply

You must be logged in to post a comment.

Search Keywords Search

Subscribe to feeds

Sourcebits

Web Design | Web Development

Categories

ActionScript (2)

Interacting with Skype from Python using Skype4P... http://query7.com/interacting-with-skype-from-pyth...

3 de 5 28-02-2012 14:07

Page 4: Python Skype

ajax (3)Android (4)Best Practices (7)book review (1)code (4)Code Igniter (3)Design (7)django (4)dropbox (2)fedora (3)Flash (2)Flex (6)Git (2)JavaScript (9)jQuery (21)kohana (4)linux (9)Mail (1)mongodb (1)nodejs (1)php (32)php-gtk (2)Programming (16)Python (9)Ruby on Rails (2)security (2)This Week in Web (25)Titanium Mobile (4)Tutorials (23)twig (2)videotutorial (4)Web 2.0 (5)Web Development (72)wordpress (1)Zend (3)

Recent Posts

This Week in Web – PHP Needs X, Python IDEs, Firefox5, jQuery Mobile,Python GamesThis Week in Web – SMF2, ZF2, Python Lamdas, Future of JS, Titanium 1.7This Week in Web -Django Hosting, Podcasts, Git Tutorials, Python Apps

Interacting with Skype from Python using Skype4P... http://query7.com/interacting-with-skype-from-pyth...

4 de 5 28-02-2012 14:07

Page 5: Python Skype

with TitaniumThis Week in Web – jQuery API, Python Video Archive, Symfony2 Beta,Heatmap.jsThis Week In Web – Python, NodeJS CMS, Google APIs, XDebug

Recent Comments

Tijmen on Titanium Mobile Android Development: First Applicationlogan on Titanium Mobile Android Development: First ApplicationTijmen on Titanium Mobile Android Development: First ApplicationTyrael on Why You Should Be Using a PHP FrameworknicoSWD on Why You Should Be Using a PHP Framework

Blogroll

Sourcebits BlogSpoonjuice BlogAndroid DevelopmentiPhone DevelopmentWeb Development

© 2011 Query7 - Powered by Wordpress.

Web Development by

Interacting with Skype from Python using Skype4P... http://query7.com/interacting-with-skype-from-pyth...

5 de 5 28-02-2012 14:07