diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 |
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 |
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/dccmove.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/dccmove.pl')
| -rw-r--r-- | scripts/dccmove.pl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/dccmove.pl b/scripts/dccmove.pl new file mode 100644 index 0000000..19a2ca9 --- /dev/null +++ b/scripts/dccmove.pl @@ -0,0 +1,45 @@ +#! /usr/bin/perl +# +# $Id: dccmove.pl,v 1.4 2007/04/17 21:32:30 peder Exp $ +# +# Copyright (C) 2003 by Peder Stray <peder@ninja.no> +# + +use Irssi; +use vars qw{$VERSION %IRSSI}; +($VERSION) = '$Revision: 1.4 $' =~ / (\d+\.\d+) /; +%IRSSI = ( + name => 'dccmove', + authors => 'Peder Stray', + contact => 'peder@ninja.no', + url => 'http://ninja.no/irssi/dccmove.pl', + license => 'GPL', + description => 'Move completed dcc gets to the subfolder done', + ); + +sub sig_dcc_closed { + my($dcc) = @_; + my($dir,$file); + + return unless $dcc->{type} eq 'GET'; + return unless -f $dcc->{file}; + + ($dir,$file) = $dcc->{file} =~ m,(.*)/(.*),; + $dir .= "/done"; + + if ($dcc->{transfd} < $dcc->{size}) { + printf('%%gDCC aborted %%_%s%%_, %%R%d%%%%%%g remaining%%n', + $file, + $dcc->{size} ? 100 - $dcc->{transfd}/$dcc->{size}*100 : 0, + ); + return; + } + + mkdir $dir, 0755 unless -d $dir; + rename $dcc->{file}, "$dir/$file"; + + printf('%%gDCC moved %%_%s%%_ to %%_%s%%_%%n', $file, $dir); + +} + +Irssi::signal_add_last('dcc closed', 'sig_dcc_closed'); |
