blob: 8505d70f337cc97fee7290c0d255e5c9c828cba6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package ASM::Fifo;
no autovivification;
use warnings;
use strict;
use POSIX qw(mkfifo);
use Fcntl;
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
sub new
{
my $module = shift;
my @args = @_;
my $self = {
"irc" => $args[0],
"conn" => $args[1]
};
mkfifo("fifo", 0777);
open( my $fifo, "+<", "fifo" );
$self->{fifo} = $fifo;
bless($self);
$self->{irc}->addfh( $self->{fifo}, $self->can('process'), 'r', $self );
return $self;
}
sub process
{
my ($self, $fifo) = @_;
my $lines;
$fifo->sysread($lines, 10240);
foreach my $line (split /\n/, $lines) {
$self->{conn}->privmsg($::settings->{masterchan}, $line); }
return 0;
}
1;
|