summaryrefslogtreecommitdiffstats
path: root/scripts/dccself.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/dccself.pl
parentInitial commit. (diff)
downloadirssi-scripts-74dedaab1f75de511e9ded8f64dcf9a4c7d2946f.tar.xz
irssi-scripts-74dedaab1f75de511e9ded8f64dcf9a4c7d2946f.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.pl38
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];
+}
+