summaryrefslogtreecommitdiffstats
path: root/scripts/dccmove.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
commit03929dac2a29664878d2c971648a4fe1fb698462 (patch)
tree02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/dccmove.pl
parentInitial commit. (diff)
downloadirssi-scripts-upstream/20231031.tar.xz
irssi-scripts-upstream/20231031.zip
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/dccmove.pl')
-rw-r--r--scripts/dccmove.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/dccmove.pl b/scripts/dccmove.pl
new file mode 100644
index 0000000..c6790fc
--- /dev/null
+++ b/scripts/dccmove.pl
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2003-2021 by Peder Stray <peder.stray@gmail.com>
+#
+
+use strict;
+use Irssi;
+use vars qw{$VERSION %IRSSI};
+($VERSION) = '$Revision: 1.4.1 $' =~ / (\d+(\.\d+)+) /;
+%IRSSI = (
+ name => 'dccmove',
+ authors => 'Peder Stray',
+ contact => 'peder.stray@gmail.com',
+ url => 'https://github.com/pstray/irssi-dccmove',
+ 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');