Skip to content

Instantly share code, notes, and snippets.

@dgl
Created November 8, 2014 12:41
Show Gist options
  • Save dgl/252dea1f11064bc6d042 to your computer and use it in GitHub Desktop.
Save dgl/252dea1f11064bc6d042 to your computer and use it in GitHub Desktop.
IRC pipe thing
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Sys::Hostname;
use IO::Async::Loop;
use Net::Async::IRC;
my $nick = hostname . "-$$";
my $server = "irc.local";
my $target;
my $text;
GetOptions(
"nick=s" => \$nick,
"server=s" => \$server,
"target=s" => \$target,
"text=s" => \$text,
) or die "Bad usage\n";
if (!$text) {
$text = join "", <>;
}
my $loop = IO::Async::Loop->new;
my $irc = Net::Async::IRC->new;
$loop->add($irc);
$irc->login(
nick => $nick,
host => $server,
)->get;
if ($target =~ /^[#&]/) {
$irc->send_message("JOIN", undef, $target);
}
$irc->send_message("PRIVMSG", undef, $target, $_) for split /\n/, $text;
$irc->send_message("QUIT", undef)->get;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment