@@ 44,6 44,7 @@ no warnings q[experimental];
use Future::AsyncAwait;
use IO::Async::Loop;
+use IO::Async::Stream;
use IO::Async::Socket;
use Net::Async::WebSocket::Client;
use Net::Async::IRC;
@@ 205,6 206,31 @@ if ($IRC_ENABLED) {
$loop->add( $irc );
}
+
+my $fifo_file = q(/petroglyph/udp2irc/gliphy.fifo);
+open my $fifo, '+<', $fifo_file
+ or die qq(cannot open $fifo_file; $! - $?);
+
+my $pipe = IO::Async::Stream->new(
+ read_handle => $fifo,
+ on_read => sub {
+ my ( $self, $buffref, $eof ) = @_;
+
+ while( $$buffref =~ s/^(.*)\n// ) {
+ my ( $room, $text ) = split /\s+/, $1, 2;
+ next unless $room and $text;
+
+ $irc->do_PRIVMSG(
+ target => $room,
+ text => $text,
+ );
+ }
+
+ return 0;
+ }
+);
+$loop->add( $pipe );
+
## setup the UDP listener
my $socket = IO::Async::Socket->new(
on_recv => sub {