]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
fnotify.pl: fixes:
authorSerge van Ginderachter <redacted>
Thu, 27 Nov 2014 17:34:31 +0000 (18:34 +0100)
committerSerge van Ginderachter <redacted>
Thu, 27 Nov 2014 17:34:31 +0000 (18:34 +0100)
fix proper way to get the irssi-dir
replace unknown err function, and do better error handling

scripts/fnotify.pl

index 42a7eb8721e68f01af4e176c24ecbe2f5200ca9d..76e46b410542efe622d8d7651b50c80ef41d509a 100644 (file)
@@ -51,7 +51,7 @@ $VERSION = '0.0.5';
 #
 sub priv_msg {
        my ($server, $msg, $nick, $address, $target) = @_;
-    my $msg_stripped = Irssi::strip_codes($msg);
+       my $msg_stripped = Irssi::strip_codes($msg);
        my $network = $server->{tag};
        filewrite('' . $network . ' ' . $nick . ' ' . $msg_stripped);
 }
@@ -73,15 +73,15 @@ sub hilight {
 #
 sub filewrite {
        my ($text) = @_;
-       # FIXME: there is probably a better way to get the irssi-dir...
-    my $fnfile = "$ENV{HOME}/.irssi/fnotify";
-    if (!open(FILE, ">>", $fnfile)) {
-        print_err("cannot open $fnfile: $!");
-    }
-       print FILE $text . "\n";
-    if (!close(FILE)) {
-        print_err("cannot close $fnfile: $!");
-    }
+       my $fnfile = Irssi::get_irssi_dir() . "/fnotify";
+       if (!open(FILE, ">>", $fnfile)) {
+               print CLIENTCRAP "Error: cannot open $fnfile: $!";
+       } else {
+               print FILE $text . "\n";
+               if (!close(FILE)) {
+                       print CLIENTCRAP "Error: cannot close $fnfile: $!";
+               }
+       }
 }
 
 #
git clone https://git.99rst.org/PROJECT