summaryrefslogtreecommitdiffstats
path: root/scripts/dccmove.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dccmove.py')
-rw-r--r--scripts/dccmove.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/dccmove.py b/scripts/dccmove.py
new file mode 100644
index 0000000..a441090
--- /dev/null
+++ b/scripts/dccmove.py
@@ -0,0 +1,33 @@
+"""
+ Translation of Perl script by Peder Stray
+"""
+
+import irssi
+import os
+from os import path
+import shutil
+
+def sig_dcc_closed(dcc):
+ if not isinstance(dcc, irssi.DccGet) or not path.isfile(dcc.file):
+ return
+
+ dir = path.dirname(dcc.file)
+ dir = path.join(dir, 'done')
+ file = path.basename(dcc.file)
+
+ if dcc.transfd < dcc.size:
+ remain = 0
+ if dcc.size:
+ remain = 100 - dcc.transfd / dcc.size * 100
+ print '%%gDCC aborted %%_%s%%_, %%R%d%%%%%%g remaining%%n' % \
+ (file, remain)
+ return
+
+ if not path.isdir(dir):
+ os.mkdir(dir, 0755)
+
+ shutil.move(dcc.file, dir)
+
+ print '%%gDCC moved %%_%s%%_ to %%_%s%%_%%n' % (file, dir)
+
+irssi.signal_add('dcc closed', sig_dcc_closed)