#!/usr/bin/env python # Skymoc. # # Python script to show current song title in skype status import time import commands import Skype4Py # , # ASCII decoding error: ordinal not in range(128) # - en_US.UTF-8 reload(sys) sys.setdefaultencoding('utf-8') # Callback def OnAttach(status): print "API Attachment status: %s" % skype.Convert.AttachmentStatusToText(status) attached = False # if status == Skype4Py.apiAttachAvailable: while not attached: try: # Public API allowed programs - skype.Attach() attached = True # - , , except: pass # Callback def OnUserStatus(status): print "Current status: %s" % status skype = Skype4Py.Skype() # skype.OnAttachmentStatus = OnAttach skype.OnUserStatus = OnUserStatus print 'Connecting to skype..' # skype.Attach(Wait=False) profile = skype.CurrentUserProfile mocpSongTitle = '' while True: # 5 , time.sleep(5) (stat, currTitle) = commands.getstatusoutput('mocp -Q %title') if currTitle != mocpSongTitle: if currTitle != '': mocpSongTitle = currTitle profile.MoodText = mocpSongTitle else: profile.MoodText = ':-)'
# def OnNotify(var): print "OnNotify: %s" % var def OnMessageStatus(chat, status): # ? ! if status == 'RECEIVED': # DynDns.org, port forwarding - ! prompt = os.popen('echo "%s" | mail -s "%s" %s' % (chat.Body, "%s via Skype" % chat.Sender.FullName, 'example@gmail.com'), 'w') sent = prompt.close() print "Sent status: %s" % sent skype = Skype4Py.Skype() skype.OnAttachmentStatus = OnAttach skype.OnNotify = OnNotify # Callback skype.OnMessageStatus = OnMessageStatus
Source: https://habr.com/ru/post/98735/
All Articles