From: bw1 Date: Sun, 11 Mar 2018 19:53:39 +0000 (+0100) Subject: [kernel] change source X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=a78b2da06998781af0761691b6373a68eb7d2d1b;p=irssi-scripts.irssi.org.git [kernel] change source --- diff --git a/scripts/kernel.pl b/scripts/kernel.pl index 048dd1d..435a068 100644 --- a/scripts/kernel.pl +++ b/scripts/kernel.pl @@ -4,56 +4,29 @@ use strict; use Irssi; -use IO::Socket; +use LWP::Simple; use vars qw($VERSION %IRSSI); -$VERSION = '0.9'; +$VERSION = '0.10'; %IRSSI = ( authors => 'Johan "Ion" Kiviniemi', contact => 'ion at hassers.org', name => 'Kernel', description => 'Fetches the version(s) of the latest Linux kernel(s).', license => 'Public Domain', - url => 'http://ion.amigafin.org/irssi/', - changed => 'Tue Mar 12 22:20 EET 2002', + url => 'http://scripts.irssi.org/', + changed => '2018-03-11', ); -sub finger($$) { - # Yes, Net::Finger is already done and i'm reinventing the wheel. - my ($user, $host) = @_; - my $buffer; - if (my $socket = IO::Socket::INET->new( - PeerHost => $host, - PeerPort => 'finger(79)', - Proto => 'tcp', - )) - { - if (syswrite $socket, "$user\n") { - unless (sysread $socket, $buffer, 1024) { - # Should i use $! here? - Irssi::print( - "Unable to read from the socket: $!", - Irssi::MSGLEVEL_CLIENTERROR - ); - } - } else { - # ..and here? - Irssi::print( - "Unable to write to the socket: $!", - Irssi::MSGLEVEL_CLIENTERROR - ); - } - } else { - Irssi::print("Connection to $host failed: $!", - Irssi::MSGLEVEL_CLIENTERROR); - } - return $buffer; +sub wget { + my $con =get("https://www.kernel.org/finger_banner"); + return $con; } sub get_version { my @version; - if (my $finger = finger("", "finger.kernel.org")) { + if (my $finger = wget()) { # The magic of the regexps :) @version = $finger =~ /:\s*(\S+)\s*$/gm; # Modify this to do whatever you want.