File: urlwindow.pl

package info (click to toggle)
irssi-scripts 20201016
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,068 kB
  • sloc: perl: 71,842; sh: 193; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,261 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
# 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.2";
%IRSSI = (
    authors     => "zdleaf",
    contact     => 'zdleaf@zinc.london', 
    name        => "urlwindow",
    description => "Log all urls from #channels and /msgs in a separate window",
    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?|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');