LinuxSir.cn,穿越时空的Linuxsir!

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

perl oicq code improved (addons 5 show friend ip)

[复制链接]
发表于 2003-4-15 16:57:11 | 显示全部楼层 |阅读模式
# the packet structure is the same as get_online_friends.
sub s_recv_friend_status {
  my ($self, $packet) = @_;
  my $plain = $self->decrypt(get_data($packet), $self->{Key});
  return unless defined $plain;
  my $srcid = unpack('N', substr($plain, 0, 4));
  my $nickname = $self->get_nickname($srcid);
  my $title = $nickname !~ /^\s*$/ ? $nickname : $srcid;
  # one byte "01" to seperate
  my $location = &get_location(substr($plain, 5, 6));
  # one byte "00" to seperate
  my $status =  &get_status(substr($plain, 12, 1));
  my $other = unpack('H*', substr($plain, 13, 20)); #some intro??
  my $my_id = substr($plain, 33, 4); # my ID
  $self->msg(substr(localtime, 11, 9),
           "$title status change status: $location\n");
  return 1;
}

sub get_location {
  my $str = shift;
  return "Unknown" unless length($str) == 6;
  my @ip = split //, substr($str, 0, 4);
  my $ip = join ".", map(ord, @ip);
  my $port = unpack('S',substr($str, 4, 2));
  return $ip;
  return ($ip !~ /^0\.0\.0\.0$/) ? "$ip" : "Unknown";  
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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