|
sub s_get_friends_list {
my ($self, $packet) = @_;
my $plain = $self->decrypt(get_data($packet), $self->{Key});
return unless defined $plain;
my $tag = substr($plain, 0, 2);
my $p = 2; my $len = length($plain);
while ($p < $len) {
my $fid = _read($plain, 'N', $p, 4); $p += 4; # one 0x00 to seperate
my $pic_idx = ord(substr($plain, $p+1, 1)); $p += 2;
my $age = ord(substr($plain, $p, 1)); $p += 1;
my $gender = ord(substr($plain, $p, 1)); $p += 1;
my $name_len = ord(substr($plain, $p, 1)); $p += 1;
my $nickname = substr($plain, $p, $name_len); $p += $name_len;
$self->{Friends}->{$fid}=
{ gender => $gender,
age => $age,
pic_idx => $pic_idx,
nickname => $nickname
};
}
if ($self->{Offline}) {
$self->output_friends_list();
return 1;
} elsif ($tag eq "\xff\xff") {
$self->output_friends_list();
} else {
$self->get_friends_list($tag);
}
return 1;
}
sub output_friends_list {
my ($self) = @_;
$self->msg("----- Friends List -----\n");
my %flist = %{$self->{Friends}}; my $fno = 1;
foreach my $fid (sort {$a <=> $b}keys %flist) {
my $friend = $flist{$fid};
$self->msg(sprintf "%2d. [%8d] %s [%3d] [pic: %3d] : %-16s \n",
$fno++, $fid,
&get_gender($friend->{gender}),
$friend->{age},
$friend->{pic_idx},
$friend->{nickname});
}
$self->msg("==========================\n");
}
sub c_get_friends_list {
my ($self, $packet) = @_;
my $plain = $self->decrypt_client_data(get_data($packet));
return unless defined $plain;
$self->desect($plain, ['H*', 'Request entire friends list', 0]);
1;
} |
|