]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
added urlwindow.pl script
authorzdleaf <redacted>
Fri, 7 Sep 2018 14:56:51 +0000 (15:56 +0100)
committerzdleaf <redacted>
Fri, 7 Sep 2018 14:56:51 +0000 (15:56 +0100)
scripts/urlwindow.pl [new file with mode: 0644]

diff --git a/scripts/urlwindow.pl b/scripts/urlwindow.pl
new file mode 100644 (file)
index 0000000..c485427
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# Print urls posted to channels or in /msg's to a window named "urls"
+#
+
+use Irssi;
+use POSIX;
+use vars qw($VERSION %IRSSI); 
+
+$VERSION = "1.0";
+%IRSSI = (
+    authors     => "zdleaf",
+    contact     => "leaf@zincldn.co.uk", 
+    name        => "urlwindow",
+    description => "Print urls to window named \"urls\"",
+    license     => "Public Domain",
+    url         => "http://irssi.org/",
+);
+               
+sub sig_printtext {
+    my ($dest, $text, $stripped) = @_;
+    
+    if(
+        (($dest->{level} & (MSGLEVEL_PUBLIC)) || ($dest->{level} & (MSGLEVEL_MSGS))) && ($text =~ qr#((?:https?://[^\s<>"]+|www\.[-a-z0-9.]+)[^\s.,;<">\):])# ) 
+               ) 
+               {
+        $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);
+    }
+}
+
+$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');
git clone https://git.99rst.org/PROJECT