Skype Python Wrapper
What is This?
- Python wrapper for skype.
- Current Version is support only low level.
- SkyNS is based on this.
Motivation
- Easy to use from Python(My favorite programing language)
- for SkyNS
Requirement
Download and Install
- Download from http://www.liris.org/program/skypewrapper.en/skypewrapper-0.1.0.zip
- extract zip file and exec the following command.
python setup.py install
- You can download sample application binary from http://www.liris.org/program/skypewrapper.en/skypeconsole-0.1.0.zip
- This is single executable file for skypeconsole.py
- kick skypeconsole.exe and type Skype API into terminal.
- You can see skpe message.
Sample Code
import os. sys. thread, import win32gui
import skypeserver
def myskypeloop(_sapi):
import time
time.sleep(1)
print "Skype Console"
while 1:
line = sys.stdin.readline()
if line.find("quit") == 0:
sys.exit(0);
if line:
args = line.split(" ")
cmd. args = args[0]. args[1:]
# find Skype api and call
f = getattr(_sapi, "skype_" + cmd)
f(*args)
sapi = skypeserver.SkypeRawServer()
sapi.connect()
thread.start_new_thread(myskypeloop, (sapi,))
win32gui.PumpMessages()
Simple Document
- Initialize Skype
- Run Windows Massage loop
- Create Message to Skype
- Callback Handler from Skype
- Create your own handler
1. Initialize SKype
import skypeserver
import win32gui
skype = skypeserver.SkypeRawServer(skypeserver.SimpleSkypeHandler)
skype.connect()
2. Run Windows message loop
# run Win32 message loop.
win32gui.PumpMessages()
3. Create Message to Skype
- The message to skpe is start with 'skype_'.
- For example, you want to search friends,
- obj.skype_SEARCH_FRIENDS()
4. Callback Handler from Skype
handler is callback handler from Skype. When we get the message from Skype,
The do_xxx method is called from SkypeRawSever.
The xxx is the Skype message's first word. If the skype send us 'USERS username1, username2',
do_USERS methon in handler is called.
For Example, you call the following::
sapi.skype_SEARCH_FRIENDS()
Then the following method in your handler is called. ::
def do_USERS(self, *args):
# args must be array of users
print args
5. Create Your Own Handler
class MyHandler:
def __init__(self, db={}): self.db = db
def do_USERS(self, *args):
self.db["USERS"] = args
and regist skypeserver at initialization
sapi = skypeserver.SkypeRawServer(MyHandler())
sap.connect()
:
More Sample Code
Skygw is the Skype Web gateway. Originally written by oyajin-san as C code. This is ported to python.
If the chat message is start with "##", the message will be translated to English to Japanese or Japanese to English using livedoor translation service.
To run script, type "python skygw.py" from console. if you are behind firewall, please specify -p proxy_host -n proxy_port as argument.
In the Future
- High level API/Class
- User/Chat/Application object
- create default handler to support minimal fuction.
Contact
- mailto: liris.pp@gmail.com