From Stealth Client

Jump to: navigation, search

Work with Skype

Description

In Stealth 7.1 added Skypeprotocol support.

Abilities:

  • User message sending
  • Threads support, sending&receiving messages.

Remember that skype support multilogin - you can connect by same login from different programs\devices.

Stealth Event for all skype events same - SkypeEventsHandler

 procedure SkypeEventsHandler(SenderId, ReceiverId, EventMsg: String; EventCode : Byte);

In Stealth you can work with Skype through variable SkypeApi - pointer to class TSkypeApi. Its methods and properties desribes lower. NO NEED to create orr dispose this class!

Script example:

 program test;
 
 procedure SkypeEventsHandler(SenderId, ReceiverId, EventMsg: String; EventCode : Byte);
 begin                             
   case EventCode of
     evCode_Connected    : AddToJournal('Skype Connected!');
     evCode_ServerDisconnected : AddToJournal('Skype Disconnected, try to reconnect!');
     evCode_ClientDisconnected : AddToJournal('Skype Disconnected.');
     evCode_MsgReceived  : AddToJournal('SkypeMsg : "' +  SkypeApi.GetNicknameById(SenderId) + '(' 
                                 + SenderId + ') ==> '
                                 +SkypeApi.GetNicknameById(ReceiverId) + '('
                                 + ReceiverId + ') : "' + EventMsg + '"');
     evCode_Error :        AddToJournal('SkypeError : "' + EventMsg + '"');
   end;  
 end; 
 
 begin  
   SetEventProc(evSkypeEvent, 'SkypeEventsHandler');
   SkypeApi.Connect('Vizit0r','some_password');
   while not SkypeApi.Connected do
     wait(200);
   SkypeApi.SendMessage('test1','some_skype_id(login)');   
   wait(1000);
   SkypeApi.SendMessage('test4444',SkypeApi.GetIdByNickname('BEST 123'));  //thread message
   wait(1000);
   AddToJournal(SkypeApi.GetIdByNickname('some_skype_NickName'));
   SkypeApi.SendMessage('test2',SkypeApi.GetIdByNickname('some_skype_NickName'));
   wait(1000);
   if SkypeApi.Connected then
     SkypeApi.Disconnect; 
 
   while True do 
     Wait(500);
 
 end.


TSkypeApi methods and properties description

  • TSkypeApi.Connect(login, password : String);
  • TSkypeApi.Disconnect;
  • SkypeApi.Connected:Boolean;
  • TSkypeApi.SendMessage(Msg : String; UserID : String);
  • TSkypeApi.GetNicknameById(ID : String): String;
  • TSkypeApi.GetIdByNickname(Nickname : String) : String;

TSkypeApi.Connect

procedure TSkypeApi.Connect(login, password : String);

Connect to server, login-password as params


TSkypeApi.Disconnect

procedure TSkypeApi.Disconnect;

Disconnect from server


TSkypeApi.Connected:Boolean

function TSkypeApi.Connected:Boolean;

Check connection status. True - connected, False - disconnected.


TSkypeApi.SendMessage

procedure TSkypeApi.SendMessage(Msg : String; UserID : String);

Send message to uuser or in thread. In UserID - user login or ID of thread


TSkypeApi.GetNicknameById

function TSkypeApi.GetNicknameById(ID : String): String;

Return nickname of user\Thread name by ID. ID - user login or ID of thread


TSkypeApi.GetIdByNickname

function TSkypeApi.GetIdByNickname(Nickname : String) : String;

Return user ID (login)\ Thread ID by Nickname\Thread name. Nickname - user nickname or Thread name.



Work with Skype from external scripts

Delphi wrapper

Same(as described above) class available as Script.Skype

Python wrapper

no class available, only couple of methods

 def Skype_Connected():
 def Skype_Connect(login, password):
 def Skype_Disconnect():
 def Skype_SendMessage(msg, user_id):
 def Skype_GetNicknameByID(user_id):
 def Skype_GetIDByNickname(user_name):