Skype: orange-dev-chat.py

File orange-dev-chat.py, 2.1 KB (added by matija, 3 years ago)

Tells Skype to join the Orange Development public chat.

Line 
1#!/usr/bin/env python
2#
3# Copyright 2011 by Bioinformatics Laboratory of Faculty of computer and
4# information science, University of Ljubljana. www.biolab.si
5#
6# Based on action_handler_1_0.py by Philipp Kolmann.
7#
8# This needs the Python DBus module.
9# In Debian you can get it via: apt-get install python-dbus
10#
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24# USA
25#
26
27import dbus
28import sys
29import re
30import string
31
32blob = '3YmIMEDziW7dEnPh25hXRfjxQUXwprR58ckoSttijwcaOmWqHnxBxOW-D7mv-ZZSgzZt'
33
34def call_skype(cmd):
35    answer = skype.Invoke(cmd)
36    return answer
37
38remote_bus = dbus.SessionBus()
39system_service_list = remote_bus.get_object('org.freedesktop.DBus',
40    '/org/freedesktop/DBus').ListNames()
41
42skype_api_found = 0
43for service in system_service_list:
44    if service=='com.Skype.API':
45        skype_api_found = 1
46        break
47
48if not skype_api_found:
49    sys.exit('No running API-capable Skype found')
50
51skype = remote_bus.get_object('com.Skype.API', '/com/Skype')
52
53
54answer = call_skype('NAME orange-dev-chat.py')
55if answer != "OK":
56    sys.exit('Error communicating with Skype!')
57
58answer = call_skype('PROTOCOL 7')
59if answer != "PROTOCOL 7":
60    sys.exit('Skype client too old!')
61
62# Connection works. Send Skype the commands ....
63
64answer = call_skype("CHAT FINDUSINGBLOB "+blob)
65chats=string.split(answer, ' ')
66if chats[0] == 'ERROR':
67    answer = call_skype("CHAT CREATEUSINGBLOB "+blob)
68    chats=string.split(answer, ' ')
69answer = call_skype("ALTER CHAT "+chats[1]+" JOIN")
70answer = call_skype("OPEN CHAT "+chats[1])