-
Notifications
You must be signed in to change notification settings - Fork 0
/
dccfwd.pl
62 lines (52 loc) · 1.33 KB
/
dccfwd.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# DCC Fwd
# Forward DCC requests
use strict;
use warnings;
use Irssi;
use Irssi::Irc;
use vars qw($VERSION %IRSSI);
$VERSION = '1.0.0';
%IRSSI = (
authors => 'Aidy',
contact => 'Aidy',
name => 'DCC Fwd',
description => 'DCC Request forwarder',
licence => 'Freeware',
);
{
my @cache = ();
$#cache = 5;
sub dccfwd_cache {
my ($dcc) = @_;
shift @cache;
push @cache, $dcc;
}
sub dccfwd_dccfind {
my ($file) = @_;
foreach (grep defined, @cache) {
return $_ if $_->{file} eq $file;
}
}
}
sub dccfwd_resume {
my ($server, $cmd, $from_user, $uhost, $dest_user) = @_;
my $fwd_nick = Irssi::settings_get_str('dccfwd_nick');
if ($cmd =~ m/^DCC RESUME ([\S]+) /) {
my $dcc = dccfwd_dccfind($1);
$dcc->{server}->command("CTCP $dcc->{nick} $cmd");
Irssi::signal_stop();
} elsif ($cmd =~ m/^DCC ACCEPT/) {
(&dccfwd_server)->command("CTCP $fwd_nick $cmd");
Irssi::signal_stop();
} elsif($cmd =~ m/^DCC SEND ([\S]+) /) {
dccfwd_cache( { file => $1, server => $server, nick => $from_user });
(&dccfwd_server)->command("CTCP $fwd_nick $cmd");
Irssi::signal_stop();
}
}
sub dccfwd_server {
return Irssi::server_find_tag( Irssi::settings_get_str('dccfwd_net') );
}
Irssi::signal_add('ctcp msg', 'dccfwd_resume');
Irssi::settings_add_str('DCCFwd', 'dccfwd_nick', '');
Irssi::settings_add_str('DCCFwd', 'dccfwd_net', '');