commit dc04523a174702541e2883129d0d324024126439 from: Izzy Blacklock date: Sun Aug 06 04:17:54 2023 UTC bug fixes; tail -f is blocking; logs should be pm not admin channels added better debug messaging. Backported from fixes in libIRCNOW branch commit - 92788e3adb0d10591ab17c83803d398a8e81c7ea commit + dc04523a174702541e2883129d0d324024126439 blob - 769896701006d59e17b892f2e62ba00dde6434d7 blob + d2c4f03ed7a419a8fc85f3a74a75be8595b2191d --- BNC.pm +++ BNC.pm @@ -309,7 +309,7 @@ sub mcontrolpanel { } } sub loadlog { - open(my $fh, '<', "$znclog") or die "Could not read file 'znc.log' $!"; + open(my $fh, '<', "$znclog") or die "Could not read znc log file: '$znclog' $!"; chomp(@logs = <$fh>); close $fh; } @@ -462,11 +462,9 @@ sub mtaillog { ($chan, $text) = ($args[0], $args[1]); } else { $text = $args[0]; } my $hostmask = "$nick!$host"; - open(my $fh, "-|", "/usr/bin/tail", "-f", $znclog) or die "could not start tail: $!"; + open(my $fh, "-|", "/usr/bin/tail", '-10', $znclog) or die "could not tail $znclog: $!"; while (my $line = <$fh>) { - foreach my $chan (@teamchans) { - main::putserv($bot, "PRIVMSG $chan :$line"); - } + main::putserv($bot, "PRIVMSG $nick :$line"); } } @@ -482,17 +480,13 @@ sub mlastseen { foreach my $user (@users) { my @lines = grep(/^\[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\] \[$user\] connected to ZNC from [.0-9a-fA-F:]+/, @logs); if (scalar(@lines) == 0) { - foreach my $chan (@teamchans) { - main::putserv($bot, "PRIVMSG $chan :$user never logged in"); - } + main::putserv($bot, "PRIVMSG $nick :$user never logged in"); next; } my $recent = pop(@lines); if ($recent =~ /^\[(\d{4}-\d\d-\d\d) \d\d:\d\d:\d\d\] \[$user\] connected to ZNC from [.0-9a-fA-F:]+/) { my $date = $1; - foreach my $chan (@teamchans) { - main::putserv($bot, "PRIVMSG $chan :$user $date"); - } + main::putserv($bot, "PRIVMSG $nick :$user $date"); } } }