Skype4COM 1.0.36.0
|
Response.vbs
This script provides a response to a message received in a chat.
Copyright � 2004-2006 Skype Limited. Licensed under BSD license.
'// Create a Skype4COM object: Set oSkype = WScript.CreateObject("Skype4COM.Skype", "Skype_") '// Start the Skype client: If Not oSkype.Client.IsRunning Then oSkype.Client.Start() End If '// Declare the following Skype constants: cAttachmentStatus_Available = oSkype.Convert.TextToAttachmentStatus("AVAILABLE") cMessageStatus_Sending = oSkype.Convert.TextToChatMessageStatus("SENDING") cMessageStatus_Received = oSkype.Convert.TextToChatMessageStatus("RECEIVED") cMessageType_Said = oSkype.Convert.TextToChatMessageType("SAID") cMessageType_Left = oSkype.Convert.TextToChatMessageType("LEFT") '// The SendMessage command will fail if the user is offline. To avoid failure, check user status and change to online if necessary: If cUserStatus_Offline = oSkype.CurrentUserStatus Then oSkype.ChangeUserStatus(cUserStatus_Online) End If '// Sleep Do While True WScript.Sleep(60000) Loop '// The AttachmentStatus event handler monitors attachment status and attempts to connect to the Skype API: Public Sub Skype_AttachmentStatus(ByVal aStatus) WScript.Echo ">Attachment status " & oSkype.Convert.AttachmentStatusToText(aStatus) If aStatus = cAttachmentStatus_Available Then oSkype.Attach() End If End Sub '// The MessageStatus event handler monitors message status, decodes received messages and, for those of type "Said", sends an autoresponse quoting the original message: Public Sub Skype_MessageStatus(ByRef aMsg, ByVal aStatus) WScript.Echo ">Message " & aMsg.Id & " status " & oSkype.Convert.ChatMessageStatusToText(aStatus) If aStatus = cMessageStatus_Received Then DecodeMsg aMsg If aMsg.Type = cMessageType_Said Then 'oSkype.SendMessage aMsg.FromHandle, "This is autoresponse." aMsg.Chat.SendMessage "You said [" & aMsg.Body & "]" End If End If End Sub '// The DecodeMsg event handler decodes messages in a chat and converts leave reasons to text for messages of type "Left": Public Sub DecodeMsg(ByRef oMsg) sText = oMsg.FromHandle & " " & oSkype.Convert.ChatMessageTypeToText(oMsg.Type) & ":" If len(oMsg.Body) Then sText = sText & " " & oMsg.Body End If Dim oUser For Each oUser In oMsg.Users sText = sText & " " & oUser.Handle Next If oMsg.Type = cMessageType_Left Then sText = sText & " " & oSkype.Convert.ChatLeaveReasonToText(oMsg.LeaveReason) End If WScript.Echo ">" & sText End Sub
Copyright � 2006 Skype Limited. All rights reserved.