Created
November 8, 2014 12:41
-
-
Save dgl/252dea1f11064bc6d042 to your computer and use it in GitHub Desktop.
IRC pipe thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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