summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Leadbeater2014-12-01 19:16:56 +0000
committerDavid Leadbeater2014-12-01 19:16:56 +0000
commit0335f79002cdcd9c264e9cc52dbfca3a77cf30b3 (patch)
treebb29079b30ab7072b784be27ee94fc3a2141b707
parentf460d1e39ac65f2a2c21f0c88aa45e9cd4217520 (diff)
parent8c80ff735d60ce8bb3f8c7267682a55d1f8065bb (diff)
downloadscripts.irssi.org-0335f79002cdcd9c264e9cc52dbfca3a77cf30b3.tar.bz2
Merge pull request #93 from srvg/fnotify
import fnotify.pl
-rw-r--r--_data/scripts.yaml10
-rw-r--r--scripts/fnotify.pl92
2 files changed, 102 insertions, 0 deletions
diff --git a/_data/scripts.yaml b/_data/scripts.yaml
index 271f5ad..f751a64 100644
--- a/_data/scripts.yaml
+++ b/_data/scripts.yaml
@@ -1348,6 +1348,16 @@
url: "http://www.krukowiecki.net/code/irssi/"
version: "0.0.2i"
+- authors: "Thorsten Leemhuis, James Shubin, Serge van Ginderachter"
+ contact: "fedora@leemhuis.info, serge@vanginderachter.be"
+ description: "Write notifications to a file in a consistent format."
+ filename: "fnotify.pl"
+ modified: "2014-11-25 21:02"
+ license: "GNU General Public License"
+ name: "fnotify"
+ url: "http://www.leemhuis.info/files/fnotify/fnotify https://ttboj.wordpress.com/"
+ version: "0.0.5"
+
- authors: "Juerd"
contact: "juerd@juerd.nl"
description: "Automatically switch to active windows"
diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl
new file mode 100644
index 0000000..76e46b4
--- /dev/null
+++ b/scripts/fnotify.pl
@@ -0,0 +1,92 @@
+use strict;
+use warnings;
+use vars qw($VERSION %IRSSI);
+use Irssi;
+
+$VERSION = '0.0.5';
+%IRSSI = (
+ name => 'fnotify',
+ authors => 'Thorsten Leemhuis, James Shubin, Serge van Ginderachter',
+ description => 'Write notifications to a file in a consistent format.',
+ license => 'GNU General Public License',
+);
+
+#
+# README
+#
+# To use:
+# $ cp fnotify.pl ~/.irssi/scripts/fnotify.pl
+# irssi> /load perl
+# irssi> /script load fnotify
+#
+
+#
+# AUTHORS
+#
+# Strip non-parsed left over codes (Bitlbee otr messages)
+# version: 0.0.5
+# Serge van Ginderachter <serge@vanginderachter.be>
+#
+# Consistent output formatting by James Shubin:
+# version: 0.0.4
+# https://ttboj.wordpress.com/
+# note: changed license back to original GPL from Thorsten Leemhuis (svg)
+#
+# Modified from the Thorsten Leemhuis <fedora@leemhuis.info>
+# version: 0.0.3
+# http://www.leemhuis.info/files/fnotify/fnotify
+#
+# In parts based on knotify.pl 0.1.1 by Hugo Haas:
+# http://larve.net/people/hugo/2005/01/knotify.pl
+#
+# Which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen:
+# http://www.irssi.org/scripts/scripts/osd.pl
+#
+# Other parts based on notify.pl from Luke Macken:
+# http://fedora.feedjack.org/user/918/
+#
+
+#
+# catch private messages
+#
+sub priv_msg {
+ my ($server, $msg, $nick, $address, $target) = @_;
+ my $msg_stripped = Irssi::strip_codes($msg);
+ my $network = $server->{tag};
+ filewrite('' . $network . ' ' . $nick . ' ' . $msg_stripped);
+}
+
+#
+# catch 'hilight's
+#
+sub hilight {
+ my ($dest, $text, $stripped) = @_;
+ if ($dest->{level} & MSGLEVEL_HILIGHT) {
+ my $server = $dest->{server};
+ my $network = $server->{tag};
+ filewrite($network . ' ' . $dest->{target} . ' ' . $stripped);
+ }
+}
+
+#
+# write to file
+#
+sub filewrite {
+ my ($text) = @_;
+ 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: $!";
+ }
+ }
+}
+
+#
+# irssi signals
+#
+Irssi::signal_add_last("message private", "priv_msg");
+Irssi::signal_add_last("print text", "hilight");
+