|
# 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";
} |
|