diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/dccself.pl | |
parent | Initial commit. (diff) | |
download | irssi-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/dccself.pl')
-rw-r--r-- | scripts/dccself.pl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/dccself.pl b/scripts/dccself.pl new file mode 100644 index 0000000..1a6ccea --- /dev/null +++ b/scripts/dccself.pl @@ -0,0 +1,38 @@ +use strict; +use vars qw/%IRSSI $VERSION/; +use Irssi qw(command_bind active_server); + +$VERSION= "0.1"; +%IRSSI = ( + authors => "David Leadbeater", + contact => "dgl\@dgl.cx", + name => "dccself", + description => "/dccself ip port, starts a dcc chat with yourself on that + host/port, best used with /set dcc_autochat_masks.", + license => "GPL", +); + +# I tried using Juerd's style for this script - seems to make it easier to read +# :) + +command_bind('dccself', sub { + my $data = shift; + my($ip,$port) = split / |:/, $data, 2; + + return unless ref active_server; + my $nick = active_server->{nick}; + $ip = dcc_ip($ip); + active_server->command("ctcp $nick DCC CHAT CHAT $ip $port"); +} ); + +sub dcc_ip { + my $ip = shift; + # This could block! + $ip = sprintf("%d.%d.%d.%d", unpack('C4',(gethostbyname($ip))[4])) + unless $ip =~ /\d$/; + + my @a = split /\./, $ip, 4; + # Thanks to perlguy/grifferz/AndrewR + return $a[0]*0x1000000 + $a[1]*0x10000 + $a[2]*0x100 + $a[3]; +} + |