perl.lt  
 
  Apie   Straipsniai   Funkcijos   Parsisiųsti   Nuorodos  
 
  Versija spausdinimui /Kodas/weather.pl - Irssi scriptas parodantis šios dienos orus ir kitos dienos trumpą prognozę./ Atgal  
 
 
#!/usr/bin/perl

use strict;
use Irssi;
use Cwd;
use vars qw($VERSION %IRSSI);

$VERSION = '1.0';
%IRSSI   = (
    authors => 'Aurimas',
    contact => 'aurimas.d\@gmail.com',
    name    => 'Weather script',
    description =>
      'Returns weather information from set location to active window',
    license  => 'Public Domain',
    changed  => 'Wed Jan 17 19:33 EEST 2007',
    commands => '/weather',
    note =>
'have curl and xsltproc commands in their places and keep weather.xslt in your scripts running directory. Check weather.com for 
your LOCID',
);

Irssi::settings_add_str( 'weather', 'curl',     '/usr/bin/curl' );
Irssi::settings_add_str( 'weather', 'xsltproc', '/usr/bin/xsltproc' );
Irssi::settings_add_str( 'weather', 'LOCID',    'LHXX0002' );
Irssi::settings_add_str( 'weather', 'units',    'm' );
Irssi::settings_add_str( 'weather', 'xslt',
    '/home/invis/weather/weather.xslt' );

sub cmd_wet {
    my $LOCID = Irssi::settings_get_str('LOCID');
    my $UNITS = Irssi::settings_get_str('units');
    my $CURLURL =
      "http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS&dayf=2";
    my $CURLCMD = Irssi::settings_get_str('curl');
    my $XSLTCMD = Irssi::settings_get_str('xsltproc');
    my $XSLT    = Irssi::settings_get_str('xslt');
    my $wet =
      `$CURLCMD \"$CURLURL\" 2>/dev/null| $XSLTCMD $XSLT - | grep -v Feels`;
    while ( $wet =~ /\n/ ) {
        $wet =~ s/\n//;
    }
    Irssi::active_win()->command( 'say ' . $wet );
}

Irssi::command_bind( 'weather', 'cmd_wet' );
 
 
 
2005.04.11 - 2012.05.21 © algirdas@perl.lt  
  Perl.lt programavimo savaitgaliai | Reklaminiai skydeliai | Perl.lt kodas