You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.1 KiB
59 lines
1.1 KiB
package Log; |
|
|
|
use Milkbone; |
|
|
|
use strict; |
|
use warnings; |
|
|
|
my $dir = option("LogDir"); |
|
|
|
register_hook("msg_in", \&on_msg_in); |
|
register_hook("protocol_send_im", \&on_protocol_send_im); |
|
register_hook("buddy_in", \&on_buddy_in); |
|
register_hook("buddy_info_changed", \&on_buddy_info_changed); |
|
register_hook("buddy_out", \&on_buddy_out); |
|
|
|
sub on_msg_in |
|
{ |
|
my ($day, $month, $year, $hour, $min, $sec) = (localtime)[4, 3, 5, 2, 1, 0]; |
|
$year += 1900; |
|
$month++; |
|
|
|
mkdir "$logdir/$ARS{-user}" unless -e "$logdir/$ARS{-user}/; |
|
log_item("$logdir/$ARS{-user}/$day-$month-$year", $ARGS{-user} . " ($day-$month-$year $hour:$min:$sec) " . |
|
": $ARGS{-msg} \n"); |
|
} |
|
|
|
sub on_buddy_in |
|
{ |
|
} |
|
|
|
sub on_buddy_info_changed |
|
{ |
|
} |
|
|
|
sub on_buddy_out |
|
{ |
|
} |
|
|
|
sub on_protocol_send_im |
|
{ |
|
my ($day, $month, $year, $hour, $min, $sec) = (localtime)[4, 3, 5, 2, 1, 0]; |
|
$year += 1900; |
|
$month++; |
|
|
|
mkdir "$logdir/$ARS{-user}" unless -e "$logdir/$ARS{-user}/; |
|
log_item("$logdir/$ARS{-user}/$day-$month-$year", data("me") . " ($day-$month-$year $hour:$min:$sec) " . |
|
": $ARGS{-msg} \n"); |
|
} |
|
|
|
sub log_item |
|
{ |
|
my ($file, $text) = @_; |
|
|
|
open(LOG, ">>$file"); |
|
print LOG $text; |
|
close(LOG); |
|
} |
|
|
|
1;
|
|
|