From 491670bc127102a81a909ac9f3ee98fdfe992e4c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 30 Aug 2020 08:41:29 -0700 Subject: add send-irssi-away-log --- .config/cron/spwhitton_athena.silentflame.com | 2 ++ .irssi/scripts/autorun/anotherway.pl | 11 ++++++--- bin/send-irssi-away-log | 32 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 bin/send-irssi-away-log diff --git a/.config/cron/spwhitton_athena.silentflame.com b/.config/cron/spwhitton_athena.silentflame.com index 4d0c4b01..0687da24 100644 --- a/.config/cron/spwhitton_athena.silentflame.com +++ b/.config/cron/spwhitton_athena.silentflame.com @@ -6,6 +6,8 @@ PATH=$HOME/local/bin:$HOME/.local/bin:$HOME/src/dotfiles/bin:/usr/local/bin:/usr # download RSS feeds a few times per day 19 */6 * * * r2e run +17 */6 * * * send-irssi-away-log + # run `importfeed --relaxed` on a machine that is always turned on, to # update podcast metadata. Actual audio files downloaded on # workstation diff --git a/.irssi/scripts/autorun/anotherway.pl b/.irssi/scripts/autorun/anotherway.pl index 7b06050b..ba360f25 100755 --- a/.irssi/scripts/autorun/anotherway.pl +++ b/.irssi/scripts/autorun/anotherway.pl @@ -28,9 +28,14 @@ sub go_away { $servers[0]->command('AWAY '.$reason); Irssi::signal_add($_ , "reset_timer") foreach (@signals); - # return to the status window so that messages received clearly - # visible in Act bar -- spw - Irssi::command('window goto 1'); + # # return to the status window so that messages received clearly + # # visible in Act bar -- spw + # Irssi::command('window goto 1'); + # ^ annoying and no longer needed now away log gets mailed to me + + # set the trackbar so we can see where we were + # -- spw + Irssi::command('tb mark'); } sub reset_timer { diff --git a/bin/send-irssi-away-log b/bin/send-irssi-away-log new file mode 100755 index 00000000..d1c38170 --- /dev/null +++ b/bin/send-irssi-away-log @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +use 5.028; +use strict; +use warnings; + +use Text::Wrap; + +our $away_log = "$ENV{HOME}/local/irclogs/away.log"; +exit unless -r $away_log; + +my $pos = 1; +if (-r "$away_log.pos") { + open my $pos_fh, "<", "$away_log.pos"; + chomp($pos = <$pos_fh>); +} + +open my $mail, "|-", "/usr/sbin/sendmail -t"; +say $mail "To: spwhitton\@spwhitton.name"; +say $mail "From: spwhitton\@spwhitton.name"; +say $mail "Subject: Irssi away.log new messages"; +say $mail ""; + +open my $fh, "<", $away_log; +while (<$fh>) { + $. > $pos or next; + s{./?}{}g; + /^[0-9]{2}:[0-9]{2}:[0-9]{2}/ and say $mail wrap "", "", $_; +} + +open my $pos_fh, ">", "$away_log.pos"; +say $pos_fh $fh->input_line_number; -- cgit v1.2.3