Flylib.com

Books Software

 
 
 

Chapter 8. Skype Chat and Voicemail


Chapter 8. Skype Chat and Voicemail

Section 8.1.  Hacks 7073: Introduction

Hack 70.  Log Chat Sessions Outside of Skype

Hack 71.  Automatically Forward Voicemail

Hack 72.  Listen to Voicemail Using a USB Handset

Hack 73.  Run Commands Remotely Using Chat



8.1. Hacks 7073: Introduction

Sometimes it is easy to forget that Skype is about more than just voice calls. Skype chat and voicemail are key features of Skype in their own rightand both are well worth hacking!

The VBScripts in this chapter use a neat COM component called ActiveS, which you can download free of charge from the KhaosLabs web site, http://www.khaoslabs.com/actives.php. It is available in both source code and binary form under a BSD-style license.

VBScripts run using Windows Scripting Host (WSH), which is available by default on Windows XP, but which you must install separately on Windows 2000. You can download WSH at http://www.microsoft.com/downloads/. Use the keyword "WSH" to find the appropriate download page.




Hack 70. Log Chat Sessions Outside of Skype

Skype can keep a history of your chat sessions, but there are many reasons why you might want to log chat sessions outside of Skype: to publish to a blog, or as an RSS feed, or just as a permanent record, for instance. This hack shows you how to build your own simple chat logger .

Works with: Windows version of Skype.

There are a multitude of reasons why you might want to keep a permanent record of your chat sessions outside of Skype in the form of a simple text file. Having such a file might be useful if you want to publish your chats to a blog, or as an RSS feed, or just for your records. Whatever the reason, switching chat logging on and off is a snap using this hack.

You can set up Skype to keep a history of your chat sessions (select Skype Tools Options Privacy Keep chat history), but each session is kept separately. So if you want the text for a particular chat session, or all chat sessions, youd better brace yourself for a lot of cut and paste! This hack provides a means of creating a single logfile outside of Skype for all of your chat sessions.

This hack uses two scripts, start_chat_log.vbs and stop_chat_log.vbs , to start and stop logging of chat sessions, respectively.

Use this script, start_chat_log.vbs , to start logging a Skype chat session:

' File: start_chat_log.vbs

	' To use this script yourself, you will need to change
	' the path and filename of the chat log file stored
	' in the variable strLogFile.

	Dim objFSO, objLogFile, objSkype, objSemaphore
	Dim strTempFolder, strSemaphoreName, strLogFile
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	Set objSkype = WScript.CreateObject("SkypeAPI.Access", _
	                                    "SkypeAPI_")
	strLogFile = "C:\Temp\Skype\ChatLog.txt"
	Set objLogFile = objFSO.OpenTextFile(strLogFile, 8, True)

	' Skype event handlers
	Sub SkypeAPI_ChatMessageSent(ChatMessage)
	Dim msg_from
	Set msg_from = ChatMessage.MessageFrom
	    objLogFile.WriteLine("Chat sent by " & msg_from.Handle & _
	                         " at " & Now & ":")
	    objLogFile.WriteLine(ChatMessage.Body)
	    objLogFile.WriteLine("")
	End Sub
	Sub SkypeAPI_ChatMessageReceived(ChatMessage)
	Dim msg_from
	Set msg_from = ChatMessage.MessageFrom
	    objLogFile.WriteLine("Chat received from " & msg_from.Handle & _
	                         " at " & Now & ":")
	    objLogFile.WriteLine(ChatMessage.Body)
	    objLogFile.WriteLine("")
	End Sub

	' Main script begins here
	strTempFolder = objFSO.GetSpecialFolder(2)
	strSemaphoreName = objFSO.BuildPath(strTempFolder, _
	                                    "chat_logging.tmp")
	Set objSemaphore = objFSO.CreateTextFile(strSemaphoreName, true)
	objSemaphore.Close
	objSkype.ConnectAndWait 15000
	Do While objFSO.FileExists(strSemaphoreName)
	    WScript.Sleep 500
	Loop
	objLogFile.Close

Use this script, stop_chat_log.vbs , to stop logging a Skype chat session:

' File: stop_chat_log.vbs

	' Main script begins here
	Dim objFSO, strTempFolder
	Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
	strTempFolder = objFSO.GetSpecialFolder(2)
	objFSO.DeleteFile objFSO.BuildPath(strTempFolder, _
	                                   "chat_logging.tmp")

The easiest way to use these scripts is to turn them into shortcuts and assign them hotkeys. Create a shortcut named Start Chat Log that points to start_chat_log.vbs as its target, then right-click on the shortcut and choose Properties. In the shortcut properties dialog that is displayed, select the tab named Shortcut, click on the text entry field opposite "Shortcut key," press the key sequence you want as your hotkey (for example, Shift-Alt-L for "Log"), and then click OK. Do the same for stop_chat_log.vbs , giving its shortcut the name Stop Chat Log and a different hotkey sequence (for example, Shift-Alt-O for "Off"). Now, beforeor even duringa chat session, you can switch logging on and off using only a couple of hotkey sequences!