![]() |
|
|
|
|
#1
|
||||
|
||||
|
дали код на C#...
Код:
try
{
for (int i = 0; i < skype.HardwiredGroups.Count; i++)
{
if (skype.HardwiredGroups[i + 1].Type == TGroupType.grpUsersWaitingMyAuthorization)
{
if (skype.HardwiredGroups[i + 1].Users.Count > 0)
{
Command newcommand1 = new Command();
newcommand1.Command = "GET GROUP "
+ skype.HardwiredGroups[i + 1].Id
+ " USERS";
newcommand1.Blocking = true;
newcommand1.Expected = "GROUP "
+ skype.HardwiredGroups[i + 1].Id
+ " USERS";
newcommand1.Timeout = 30000;
skype.SendCommand(newcommand1);
if (newcommand1.Reply.StartsWith(newcommand1.Expected))
{
string[] Allresults = newcommand1.Reply.ToString().Replace("GROUP " + skype.HardwiredGroups[i + 1].Id + " USERS", "").Replace(" ", "").Split(new Char[] { ',' });
if (Allresults[0].Length > 0)
{
for (int j = Allresults.Length; j > 0; j--)
{
Command newcommand2 = new Command();
newcommand2.Command = "SET USER "
+ Allresults[j - 1].ToString()
+ " BUDDYSTATUS 2";
newcommand2.Blocking = true;
newcommand2.Expected = "USER "
+ Allresults[j - 1].ToString()
+ " BUDDYSTATUS 3";
newcommand2.Timeout = 30000;
skype.SendCommand(newcommand2);
if (!newcommand2.Reply.StartsWith(newcommand2.Expected))
MessageBox.Show("Bad Reply for: "
+ newcommand2.Command.ToString()
+ " Reply: "
+ newcommand2.Reply.ToString());
}
}
}
else
MessageBox.Show("Hardwired Group Reply Error: " + newcommand1.Reply.ToString());
}
break;
}
}
}
catch (Exception e)
{
// All Skype Logic uses TRY for safety
MessageBox.Show("Pending Authorization Group Error- Exception Source: " + e.Source + " - Exception Message: " + e.Message);
}
Код:
try
begin
for (int i = 0; i < skype.HardwiredGroups.Count; i++)
begin
if (skype.HardwiredGroups[i + 1].Type == TGroupType.grpUsersWaitingMyAuthorization)
begin
if (skype.HardwiredGroups[i + 1].Users.Count > 0)
begin
Command newcommand1 = new Command();
newcommand1.Command = 'GET GROUP '
+ skype.HardwiredGroups[i + 1].Id
+ ' USERS';
newcommand1.Blocking = true;
newcommand1.Expected = 'GROUP '
+ skype.HardwiredGroups[i + 1].Id
+ ' USERS';
newcommand1.Timeout = 30000;
skype.SendCommand(newcommand1);
if (newcommand1.Reply.StartsWith(newcommand1.Expected))
begin
string[] Allresults = newcommand1.Reply.ToString().Replace('GROUP ' + skype.HardwiredGroups[i + 1].Id + ' USERS', '').Replace(' ', '').Split(new Char[] begin ',' end);
if (Allresults[0].Length > 0)
begin
for (int j = Allresults.Length; j > 0; j--)
begin
Command newcommand2 = new Command();
newcommand2.Command = 'SET USER '
+ Allresults[j - 1].ToString()
+ ' BUDDYSTATUS 2';
newcommand2.Blocking = true;
newcommand2.Expected = 'USER '
+ Allresults[j - 1].ToString()
+ ' BUDDYSTATUS 3';
newcommand2.Timeout = 30000;
skype.SendCommand(newcommand2);
if (!newcommand2.Reply.StartsWith(newcommand2.Expected))
MessageBox.Show('Bad Reply for: '
+ newcommand2.Command.ToString()
+ ' Reply: '
+ newcommand2.Reply.ToString());
end
end
end
else
MessageBox.Show('Hardwired Group Reply Error: ' + newcommand1.Reply.ToString());
end
break;
end
end
end
catch (Exception e)
begin
// All Skype Logic uses TRY for safety
MessageBox.Show('Pending Authorization Group Error- Exception Source: ' + e.Source + ' - Exception Message: ' + e.Message);
end |
|
#2
|
||||
|
||||
|
MessageBox.Show это наверно ShowMessage
|
|
#3
|
|||
|
|||
|
Цитата:
|
|
#4
|
||||
|
||||
|
begin и end и " на ' по логике понял) остальное незнаю
|
|
#5
|
|||
|
|||
|
Как-то так
Код:
var
i, j: Integer;
newcommand1, newcommand2: Command;
Allresults: TStringList;
try
for i := 0 to skype.HardwiredGroups.Count-1 do
begin
// здесь скорее всего поле Type имеет другое значение, т.к. в Delphi оно ключевое
if skype.HardwiredGroups[i + 1].Type = TGroupType.grpUsersWaitingMyAuthorization then
begin
if skype.HardwiredGroups[i + 1].Users.Count > 0 then
begin
newcommand1.Command = 'GET GROUP '
+ skype.HardwiredGroups[i + 1].Id
+ ' USERS';
newcommand1.Blocking = true;
newcommand1.Expected = 'GROUP '
+ skype.HardwiredGroups[i + 1].Id
+ ' USERS';
newcommand1.Timeout = 30000;
skype.SendCommand(newcommand1);
if newcommand1.Reply.StartsWith(newcommand1.Expected) then
begin
Allresults := TStringList.Create;
// тут сразу много операций =)
// 1. представление newcommand1.Reply в строковом виде
// 2. замена строки 'GROUP ' + skype.HardwiredGroups[i + 1].Id + ' USERS' на ''
// 3. замена строки ' ' на ''
// 4. формируется новый массив строк, содержащий подстроки пердыдущей строки, разделенные запятой
//string[] Allresults = newcommand1.Reply.ToString().Replace("GROUP " + skype.HardwiredGroups[i + 1].Id + " USERS", "").Replace(" ", "").Split(new Char[] { ',' });
if Allresults.Count > 0 then
begin
for j := Allresults.Count-1 downto 0 do
begin
newcommand2.Command = 'SET USER '
+ Allresults[j]
+ ' BUDDYSTATUS 2';
newcommand2.Blocking = true;
newcommand2.Expected = 'USER '
+ Allresults[j]
+ ' BUDDYSTATUS 3';
newcommand2.Timeout = 30000;
skype.SendCommand(newcommand2);
if not newcommand2.Reply.StartsWith(newcommand2.Expected) then
ShowMessage('Bad Reply for: '
// это встоенный метод представление этого значения строкой (нужно использовать стандартные IntToStr или FloatToStr)
+ newcommand2.Command.ToString()
+ ' Reply: '
+ newcommand2.Reply.ToString());
end;
end;
Allresults.Free;
end;
else
ShowMessage('Hardwired Group Reply Error: ' + newcommand1.Reply.ToString());
end;
break;
end;
end;
except
on E : Exception do
ShowMessage('Pending Authorization Group Error- Exception Source: ' + e.ClassName + ' - Exception Message: ' + e.Message);
end; |
|
#6
|
|||
|
|||
|
ага, только в переменных не =, а :=
|
|
#7
|
||||
|
||||
|
благодарю!
|