# Moodgeist pinger reference client # see http://www.moodgeist.com/ # you will also need Python Skype API wrapper from this link: # http://www.liris.org/program/skypewrapper.en/program/skypewrapper.en/ import os, sys, thread, win32gui, string, skypeserver, time from datetime import datetime import urllib moodgeist_ping_url = 'http://www.moodgeist.com/do/ping/' poster = '' globalvar = {} globalvar['user_profiles'] = {} def trigger_get_property(cmd, args, _sapi): f = getattr(_sapi, "skype_" + cmd) f(*args) def init_users(_sapi): global globalvar trigger_get_property("SEARCH", ('FRIENDS',), _sapi) while (not globalvar.has_key('users')): time.sleep(1) print "Contacts found: " + str(len(globalvar['users'])) for user in globalvar['users']: # time.sleep(1); trigger_get_property("GET", ('USER', user, 'LANGUAGE'), _sapi) trigger_get_property("GET", ('USER', user, 'MOOD_TEXT'), _sapi) class MyHandler: # the blank ones are here just to shut up the console - otherwise it complains it doesnt have handlers # for these calls. you can uncomment them and then you see. or you can write some # interesting handlers here. def do_CURRENTUSERHANDLE(self, *args): global poster poster = args[0] print "Current user: " + poster def do_USERSTATUS(self, *args): pass def do_CONNSTATUS(self, *args): pass def do_USERS(self, *args): globalvar['users'] = [] for user in args: globalvar['users'].append(user.replace(',','')) def do_GROUP(self, *args): pass def do_CONTACTS(self, *args): pass def do_CALL(self, *args): pass def do_VOICEMAIL(self, *args): pass def do_CHAT(self, *args): pass def do_CHATMESSAGE(self, *args): pass def do_LANGUAGE(self, *args): pass # just for info def do_PROTOCOL(self, *args): print "Using Skype API protocol", string.join(args, ' ') def do_ERROR(self, *args): print 'Error from Skype API: ' + string.join(args, ' ') def do_USER(self, *args): global poster, globalvar # print args[0:] if ((args[1] == 'MOOD_TEXT') or (args[1] == 'LANGUAGE')): if (not globalvar['user_profiles'].has_key(args[0])): globalvar['user_profiles'][args[0]] = {} if (args[1] == 'MOOD_TEXT'): globalvar['user_profiles'][args[0]]['MOOD_TEXT'] = string.join(args[2:], ' ') if (args[1] == 'LANGUAGE'): globalvar['user_profiles'][args[0]]['LANGUAGE'] = args[2] if (globalvar['user_profiles'][args[0]].has_key('MOOD_TEXT')): params = urllib.urlencode({'protocol': 1, 'skypename': args[0], 'poster': poster, 'mood_text': globalvar['user_profiles'][args[0]]['MOOD_TEXT'], 'skypename_language': globalvar['user_profiles'][args[0]]['LANGUAGE']}) f = urllib.urlopen(moodgeist_ping_url, params) print "Pinged mood for Skype Name " + args[0] + ', got: ' + f.read() def myskypeloop(_sapi): time.sleep(3); trigger_get_property("GET", ("CURRENTUSERHANDLE",), _sapi) trigger_get_property("PROTOCOL", ("5",), _sapi) print "Hit Ctrl-C or Ctrl-Break to quit."; init_users(_sapi) while 1: line = sys.stdin.readline() if line.find("quit") == 0: # umm doesnt work... you cant manually exit this way from within a thread? sys.exit(0); sapi = skypeserver.SkypeRawServer(MyHandler()) sapi.connect() thread.start_new_thread(myskypeloop, (sapi,)) win32gui.PumpMessages()