Help - Search - Members - Calendar
Full Version: How do I connect to public chat
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
ewoo
I startup skype and create a public chat called 'bingo' with contact being added. I then try to run the script below.
'===============================================================
Set oSkype = WScript.CreateObject("Skype4COM.Skype","Skype_")
If Not oSkype.Client.IsRunning Then oSkype.Client.Start() End If
Set oChat = oSkype.Chat("bingo")
oChat.SendMessage("It Works!")
oChat.Leave
Public Sub Skype_AttachmentStatus(ByVal aStatus)
WScript.Echo ">Attachment status " & oSkype.Convert.AttachmentStatusToText(aStatus)
If aStatus = oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then oSkype.Attach() End If
End Sub
'===============================================================

However I get the following error

Script: tskpe.vbs
Line: 4
Char: 1
Error: Invalid/uknown chat name given
Code: 80020009
Source: Skype4Com.Skype.1


My version Skype is 3.5.0.239
COM wrapper version 1.0.27.1

Would anyone know what's wrong with my script? Thanks
TheUberOverlord
QUOTE(ewoo @ Wed Sep 26 2007, 13:41) [snapback]445554[/snapback]

I startup skype and create a public chat called 'bingo' with contact being added. I then try to run the script below.
'===============================================================
Set oSkype = WScript.CreateObject("Skype4COM.Skype","Skype_")
If Not oSkype.Client.IsRunning Then oSkype.Client.Start() End If
Set oChat = oSkype.Chat("bingo")
oChat.SendMessage("It Works!")
oChat.Leave
Public Sub Skype_AttachmentStatus(ByVal aStatus)
WScript.Echo ">Attachment status " & oSkype.Convert.AttachmentStatusToText(aStatus)
If aStatus = oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then oSkype.Attach() End If
End Sub
'===============================================================

However I get the following error

Script: tskpe.vbs
Line: 4
Char: 1
Error: Invalid/uknown chat name given
Code: 80020009
Source: Skype4Com.Skype.1
My version Skype is 3.5.0.239
COM wrapper version 1.0.27.1

Would anyone know what's wrong with my script? Thanks


Does this help?

http://forum.skype.com/index.php?s=&sh...st&p=442182
ewoo
QUOTE(TheUberOverlord @ Wed Sep 26 2007, 19:46) [snapback]445556[/snapback]



This is a get around of what I would like to do. What I am hoping to do is not to have the script setup the public chat with user. The script should only be able to sendMessage to the public chat. Does current API allow me to do that? Thanks.
Avo Nappo
> The script should only be able to sendMessage to the public chat. Does current API allow me to do that?

API has allowed it sionce I think version 3.0. In Skype4Com wrapper the public chats part of the API was only included in version 1.0.28 (available as download on DevZone). With 1.0.28 you can do it as follows (Delphi example again but its interacting with ActiveX anyway so should be easy re-use in another languages):


CODE


//------------------------------------------------------------------------------
//  Skype API, Public Chats Test
//  for Delphi, using Skype4Com library
//
//  Tested with Delphi 5, Skype4Com v.1.0.28, Skype v.3.5.0.214
//
//  NB! This example will NOT work properly with Skype4Com versions
//  below 1.0.28.
//
//  To use the code in this example:
//  1. Create new application. A form named Form1 should be created automatically
//  2. Drag and drop following 2 components onto Form1:
//   2.1 Standard Memo component named Memo1
//   2.2 Two standard Button components named Button1 and Button2
//  3. Copy & paste this exaple into Form1's code editor.
//  4. Go to Form view and link following events:
//   4.1 Form1.OnCreate -> FormCreate
//   4.2 Button1.OnClick -> Button1Click
//   4.2 Button2.OnClick -> Button2Click


Unit Unit1;

Interface

Uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SKYPE4COMLib_TLB, OleServer;

Const Protocol = 8;


// NB! Change this constant to your own public chat BLOB
// To get a public chat BLOB, create a public chat in Skype UI, then:
// 1. From chat window menu: Options / Promote chat
// 2. click on Copy link on clipboard
// 3. paste the link here
// 4. from the link, take everything that follows substring '&blob=', thats the BLOB
// 5. Assign that BLOB to MyBLOB constant.

Const MyBLOB = 'F-0u9S6LhayaPzpJNxRVhjFyVK_Yw-7OtS3fQn14C-xTBp92kKUTuY39sDSQ8F7v';

Type
  TForm1 = Class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;

    Procedure FormCreate(Sender: TObject);
    Procedure OnSkypeAttachmentStatus(Sender: TObject; Status: TOleEnum);

    Procedure OpenPublicChat(Sender: TObject);
    Procedure SendMessage (Sender: TObject);

    Procedure OnSkypeChatMembersChanged (ASender: TObject;
              const pChat: IChat;
              const pMembers: IUserCollection);

    Procedure OnSkypeChatMemberRoleChanged (ASender: TObject;
              const pMember: IChatMember;
              Role: TChatMemberRole);

  Private
    Skype   : TSkype;
    MyPublicChat : IChat;
  End;

Var
  Form1: TForm1;

Implementation

{$R *.dfm}

Procedure TForm1.OpenPublicChat (Sender : TObject);

Begin
  Try
    MyPublicChat := Skype.FindChatUsingBlob(MyBLOB);
  Except
    MyPublicChat := Skype.CreateChatUsingBlob(MyBLOB);
  End;
  MyPublicChat.Join;
  MyPublicChat.OpenWindow;
End;

Procedure TForm1.SendMessage (Sender : TObject);

Begin
  Try
    MyPublicChat.SendMessage('ping!!');
  Except
    Memo1.Lines.Add('Cannot ping. Is the chat open? I think it isn''t..');
  End;
End;


Procedure TForm1.FormCreate(Sender: TObject);

Begin
  Skype := TSkype.Create(Self);
  Skype.OnAttachmentStatus              := OnSkypeAttachmentStatus;
  Skype.OnChatMembersChanged            := OnSkypeChatMembersChanged;
  Skype.OnChatMemberRoleChanged         := OnSkypeChatMemberRoleChanged;

  Caption := 'Public Chat Test';
  Memo1.Clear;
  Memo1.Align := alClient;
  Button1.Align := alBottom;
  Button1.Caption := 'Connect';
  Button2.Align := alBottom;
  Button2.Caption := 'Ping';

// Attaching to Skype
  Skype.Attach(Protocol, False);
End;

Procedure Log (S : String);

Begin
  Form1.Memo1.Lines.Add(S);
End;


Procedure TForm1.OnSkypeAttachmentStatus(Sender: TObject; Status: TOleEnum);

Begin
Memo1.Lines.Add('Skype attatchment status: ' + Skype.Convert.AttachmentStatusToText(Status));
if Status = apiAttachAvailable Then Skype.Attach(Protocol, False);
End;


Procedure TForm1.OnSkypeChatMembersChanged (ASender: TObject;
              const pChat: IChat;
              const pMembers: IUserCollection);

Begin
  Log('OnSkypeChatMembersChanged event fired for ' +
    pChat.FriendlyName +
    '. New usercount: ' +
    IntToStr(pMembers.Count));
End;

Procedure TForm1. OnSkypeChatMemberRoleChanged (ASender: TObject;
              const pMember: IChatMember;
              Role: TChatMemberRole);

Var S : String;

Begin
  Log('OnSkypeChatMemberRoleChanged event fired');
  Case Role of
    $FFFFFFFF : S := 'MemberRoleUnknown';
    0 : S := 'MemberRoleCreator';
    1 : S := 'MemberRoleMaster';
    2 : S := 'MemberRoleHelper';
    3 : S := 'MemberRoleUser';
    4 : S := 'MemberRoleListener';
    5 : S := 'MemberRoleApplicant';
  End;
  Log (pMember.Handle + ' role: ' + S);
End;

End.


ewoo
QUOTE(Avo Nappo @ Thu Sep 27 2007, 12:04) [snapback]445818[/snapback]

> The script should only be able to sendMessage to the public chat. Does current API allow me to do that?

API has allowed it sionce I think version 3.0. In Skype4Com wrapper the public chats part of the API was only included in version 1.0.28 (available as download on DevZone). With 1.0.28 you can do it as follows (Delphi example again but its interacting with ActiveX anyway so should be easy re-use in another languages):
CODE


//------------------------------------------------------------------------------
//  Skype API, Public Chats Test
//  for Delphi, using Skype4Com library
//
//  Tested with Delphi 5, Skype4Com v.1.0.28, Skype v.3.5.0.214
//
//  NB! This example will NOT work properly with Skype4Com versions
//  below 1.0.28.
//
//  To use the code in this example:
//  1. Create new application. A form named Form1 should be created automatically
//  2. Drag and drop following 2 components onto Form1:
//   2.1 Standard Memo component named Memo1
//   2.2 Two standard Button components named Button1 and Button2
//  3. Copy & paste this exaple into Form1's code editor.
//  4. Go to Form view and link following events:
//   4.1 Form1.OnCreate -> FormCreate
//   4.2 Button1.OnClick -> Button1Click
//   4.2 Button2.OnClick -> Button2Click
Unit Unit1;

Interface

Uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SKYPE4COMLib_TLB, OleServer;

Const Protocol = 8;
// NB! Change this constant to your own public chat BLOB
// To get a public chat BLOB, create a public chat in Skype UI, then:
// 1. From chat window menu: Options / Promote chat
// 2. click on Copy link on clipboard
// 3. paste the link here
// 4. from the link, take everything that follows substring '&blob=', thats the BLOB
// 5. Assign that BLOB to MyBLOB constant.

Const MyBLOB = 'F-0u9S6LhayaPzpJNxRVhjFyVK_Yw-7OtS3fQn14C-xTBp92kKUTuY39sDSQ8F7v';

Type
  TForm1 = Class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;

    Procedure FormCreate(Sender: TObject);
    Procedure OnSkypeAttachmentStatus(Sender: TObject; Status: TOleEnum);

    Procedure OpenPublicChat(Sender: TObject);
    Procedure SendMessage (Sender: TObject);

    Procedure OnSkypeChatMembersChanged (ASender: TObject;
              const pChat: IChat;
              const pMembers: IUserCollection);

    Procedure OnSkypeChatMemberRoleChanged (ASender: TObject;
              const pMember: IChatMember;
              Role: TChatMemberRole);

  Private
    Skype   : TSkype;
    MyPublicChat : IChat;
  End;

Var
  Form1: TForm1;

Implementation

{$R *.dfm}

Procedure TForm1.OpenPublicChat (Sender : TObject);

Begin
  Try
    MyPublicChat := Skype.FindChatUsingBlob(MyBLOB);
  Except
    MyPublicChat := Skype.CreateChatUsingBlob(MyBLOB);
  End;
  MyPublicChat.Join;
  MyPublicChat.OpenWindow;
End;

Procedure TForm1.SendMessage (Sender : TObject);

Begin
  Try
    MyPublicChat.SendMessage('ping!!');
  Except
    Memo1.Lines.Add('Cannot ping. Is the chat open? I think it isn''t..');
  End;
End;
Procedure TForm1.FormCreate(Sender: TObject);

Begin
  Skype := TSkype.Create(Self);
  Skype.OnAttachmentStatus              := OnSkypeAttachmentStatus;
  Skype.OnChatMembersChanged            := OnSkypeChatMembersChanged;
  Skype.OnChatMemberRoleChanged         := OnSkypeChatMemberRoleChanged;

  Caption := 'Public Chat Test';
  Memo1.Clear;
  Memo1.Align := alClient;
  Button1.Align := alBottom;
  Button1.Caption := 'Connect';
  Button2.Align := alBottom;
  Button2.Caption := 'Ping';

// Attaching to Skype
  Skype.Attach(Protocol, False);
End;

Procedure Log (S : String);

Begin
  Form1.Memo1.Lines.Add(S);
End;
Procedure TForm1.OnSkypeAttachmentStatus(Sender: TObject; Status: TOleEnum);

Begin
Memo1.Lines.Add('Skype attatchment status: ' + Skype.Convert.AttachmentStatusToText(Status));
if Status = apiAttachAvailable Then Skype.Attach(Protocol, False);
End;
Procedure TForm1.OnSkypeChatMembersChanged (ASender: TObject;
              const pChat: IChat;
              const pMembers: IUserCollection);

Begin
  Log('OnSkypeChatMembersChanged event fired for ' +
    pChat.FriendlyName +
    '. New usercount: ' +
    IntToStr(pMembers.Count));
End;

Procedure TForm1. OnSkypeChatMemberRoleChanged (ASender: TObject;
              const pMember: IChatMember;
              Role: TChatMemberRole);

Var S : String;

Begin
  Log('OnSkypeChatMemberRoleChanged event fired');
  Case Role of
    $FFFFFFFF : S := 'MemberRoleUnknown';
    0 : S := 'MemberRoleCreator';
    1 : S := 'MemberRoleMaster';
    2 : S := 'MemberRoleHelper';
    3 : S := 'MemberRoleUser';
    4 : S := 'MemberRoleListener';
    5 : S := 'MemberRoleApplicant';
  End;
  Log (pMember.Handle + ' role: ' + S);
End;

End.




Thanks for you information. How do I get the version 1.0.28? I only see the release version 1.0.27 in DevZone Download. Please provide me a link if possible. Thanks again.

I also notice the BLOB. Is this new? I did not find it in the API Doc. Would you be able to tell me how to get the blob from my Skype. Thanks.
Avo Nappo
> Thanks for you information. How do I get the version 1.0.28?

You can get the 1.0.28 beta from https://developer.skype.com/Docs/Skype4COM

Release version will be available as soon as Skype 3.6 gets released.

> I also notice the BLOB. Is this new? I did not find it in the API Doc.

Blobs have been there since 3.0, the relevant portion of API reference is:
https://developer.skype.com/Docs/ApiDoc/Public_Chats

> Would you be able to tell me how to get the blob from my Skype.

I think you missed the following comment in the Delphi example:

// NB! Change this constant to your own public chat BLOB
// To get a public chat BLOB, create a public chat in Skype UI, then:
// 1. From chat window menu: Options / Promote chat
// 2. click on Copy link on clipboard
// 3. paste the link here
// 4. from the link, take everything that follows substring '&blob=', thats the BLOB
// 5. Assign that BLOB to MyBLOB constant.
TheUberOverlord
Am I missing something?

In my first post I included this:

http://forum.skype.com/index.php?s=&sh...st&p=442182

Which shows how to create a public chat. Once that was done, could

chat.Blob not be checked and that value saved so that you could use it in the future?

Or even search chats and look for that topic and or other fields to gain chat.Blob programmatically?

Of course this would only work with version .28 of Skype4COM Lib.
ewoo
QUOTE(Avo Nappo @ Fri Sep 28 2007, 10:19) [snapback]446164[/snapback]

> Thanks for you information. How do I get the version 1.0.28?

You can get the 1.0.28 beta from https://developer.skype.com/Docs/Skype4COM

Release version will be available as soon as Skype 3.6 gets released.

> I also notice the BLOB. Is this new? I did not find it in the API Doc.

Blobs have been there since 3.0, the relevant portion of API reference is:
https://developer.skype.com/Docs/ApiDoc/Public_Chats

> Would you be able to tell me how to get the blob from my Skype.

I think you missed the following comment in the Delphi example:

// NB! Change this constant to your own public chat BLOB
// To get a public chat BLOB, create a public chat in Skype UI, then:
// 1. From chat window menu: Options / Promote chat
// 2. click on Copy link on clipboard
// 3. paste the link here
// 4. from the link, take everything that follows substring '&blob=', thats the BLOB
// 5. Assign that BLOB to MyBLOB constant.

Thank you for your information.
I did download the latest beta version and override the version on my \windows\system32\ dir
However, it does not have the CreateChatUsingBlob() method for sykpe object. while running wscript.
Do you know what might be the problem? I download the Skype4COM-1.0.28-beta3.zip
ewoo
I figure out what's wrong. I did not unregister Skype4com.dll before I install the new version.

Thanks Guys
TheUberOverlord
QUOTE(ewoo @ Sat Sep 29 2007, 20:26) [snapback]446671[/snapback]

I figure out what's wrong. I did not unregister Skype4com.dll before I install the new version.

Thanks Guys


You are very welcome.
Avo Nappo
Anyhow, just in case, I updated the Skype4Com beta dowload file at https://developer.skype.com/Docs/Skype4COM to beta4, which is (hopefully) what will get distributed with Skype 3.6
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.