summaryrefslogtreecommitdiffstats
path: root/scripts/urlwindow.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/urlwindow.pl
parentInitial commit. (diff)
downloadirssi-scripts-upstream/20231031.tar.xz
irssi-scripts-upstream/20231031.zip
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--scripts/urlwindow.pl47
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/urlwindow.pl b/scripts/urlwindow.pl
new file mode 100644
index 0000000..4016285
--- /dev/null
+++ b/scripts/urlwindow.pl
@@ -0,0 +1,47 @@
+#
+# Logs all urls from #channels and /msgs in a separate window called "urls"
+#
+
+use Irssi;
+use POSIX;
+use vars qw($VERSION %IRSSI);
+use strict;
+
+$VERSION = "1.4";
+%IRSSI = (
+ authors => "zdleaf",
+ contact => 'zdleaf@zinc.london',
+ name => "urlwindow",
+ description => "Log all urls from #channels and /msgs in a separate window",
+ license => "Public Domain",
+);
+
+sub sig_printtext {
+ my ($dest, $text, $stripped) = @_;
+
+ if((($dest->{level} & (MSGLEVEL_PUBLIC)) || ($dest->{level} & (MSGLEVEL_MSGS)))
+ && ($text =~
+ qr#((?:(https?|gopher|ftp)://[^\s<>"]+|www\.[-a-z0-9.]+)[^\s.,;<">\):])# ))
+ {
+ my $window = Irssi::window_find_name('urls');
+
+ if ($dest->{level} & MSGLEVEL_PUBLIC) {
+ $text = $dest->{target}.": ".$text;
+ }
+
+ $text = strftime(
+ Irssi::settings_get_str('timestamp_format')." ",
+ localtime
+ ).$text;
+ $window->print($text, MSGLEVEL_NEVER) if ($window);
+ }
+}
+
+my $window = Irssi::window_find_name('urls');
+
+if (!$window) {
+ $window = Irssi::Windowitem::window_create('urls', 1);
+ $window->set_name('urls');
+}
+
+Irssi::signal_add('print text', 'sig_printtext');