summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge van Ginderachter2014-11-27 18:34:31 +0100
committerSerge van Ginderachter2014-11-27 18:34:31 +0100
commit8c80ff735d60ce8bb3f8c7267682a55d1f8065bb (patch)
treed94625c304be1f2727f3aedb940c3c11212ff5ae
parent3a92a5e3d05d2eee78fc9202a673b1861563c60c (diff)
downloadscripts.irssi.org-8c80ff735d60ce8bb3f8c7267682a55d1f8065bb.tar.bz2
fnotify.pl: fixes:
fix proper way to get the irssi-dir replace unknown err function, and do better error handling
-rw-r--r--scripts/fnotify.pl20
1 files changed, 10 insertions, 10 deletions
diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl
index 42a7eb8..76e46b4 100644
--- a/scripts/fnotify.pl
+++ b/scripts/fnotify.pl
@@ -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: $!";
+ }
+ }
}
#