LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2341|回复: 0

perl oicq code improved (addons 2, function get_friends_list)

[复制链接]
发表于 2003-4-15 16:53:54 | 显示全部楼层 |阅读模式
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;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表