summaryrefslogtreecommitdiffstats
path: root/scripts/away2web.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
commit03929dac2a29664878d2c971648a4fe1fb698462 (patch)
tree02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/away2web.pl
parentInitial commit. (diff)
downloadirssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz
irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/away2web.pl')
-rw-r--r--scripts/away2web.pl58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/away2web.pl b/scripts/away2web.pl
new file mode 100644
index 0000000..7414c23
--- /dev/null
+++ b/scripts/away2web.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+use strict;
+use vars qw($VERSION %IRSSI);
+$VERSION = "2003100201";
+%IRSSI = (
+ authors => "Oskari 'Okko' Ojala",
+ contact => "sorter.irssi-scripts\@okko.net",
+ name => "away2web",
+ description => "Write /away information to a file to be used on web pages",
+ license => "BSD",
+ changed => "$VERSION",
+);
+use Irssi 20020324;
+
+#
+# Writes /away information to a file. A web page script (cgi / php / pl..) can
+# then read the file and display online/offline information.
+#
+# The web page script is left as an excersise for the user because the platforms
+# vary. :-)
+#
+# Tip: You can also modify this script to directly write HTML and then just include
+# the file on your web page.
+#
+#
+# Format of the file:
+# First line: Either "1" or "0". 0=Offline (away), 1=Online (not away).
+# Second line: The away reason (message). If the user is Online, second line is
+# empty but exists.
+#
+# File is written to ~/.irssi/away2web-status.
+#
+
+sub catch_away {
+ my $server = shift;
+
+ open(STATUSFILE, q{>}, $ENV{'HOME'}.'/.irssi/away2web-status') || die ("away2web.pl: Could not open file for writing:".$!);
+
+ if ($server->{usermode_away}) {
+ # User is offline.
+ print STATUSFILE "0\n";
+ } else {
+ # User is online.
+ print STATUSFILE "1\n";
+ }
+
+ print STATUSFILE $server->{'away_reason'}."\n";
+
+ close(STATUSFILE);
+
+}
+
+Irssi::signal_add("away mode changed", "catch_away");
+
+print CLIENTCRAP '%B>>%n '.$IRSSI{name}.' '.$VERSION.' (c) '.$IRSSI{authors}.' loaded';
+
+# end of script.