summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2015-12-26 20:23:48 -0700
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2015-12-26 20:23:48 -0700
commit2a85bdefca654241cc16939890236300516cfb0b (patch)
tree2f036fd7eb5eec42633b73a14f0b0af629b86ea4
parent786e5f91e16bc3a709ef06d0ffa1808bd92a6451 (diff)
Create a fifo, relay it into masterchan (awesome for git web hook, and for making dwfreed wonder how the bot is talking)
-rw-r--r--lib/ASM/Fifo.pm33
-rwxr-xr-xmeta.pl2
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/ASM/Fifo.pm b/lib/ASM/Fifo.pm
new file mode 100644
index 0000000..1a480f8
--- /dev/null
+++ b/lib/ASM/Fifo.pm
@@ -0,0 +1,33 @@
+package ASM::Fifo;
+
+use warnings;
+use strict;
+use POSIX qw(mkfifo);
+use Fcntl;
+
+sub new
+{
+ my $module = shift;
+ my @args = @_;
+ my $self = {
+ "irc" => $args[0],
+ "conn" => $args[1]
+ };
+ mkfifo("fifo", 0777);
+ sysopen( my $fifo, "fifo", O_NONBLOCK );
+ $self->{fifo} = $fifo;
+ bless($self);
+ $self->{irc}->addfh( $self->{fifo}, sub { $self->process(@_); }, 'r' );
+ return $self;
+}
+
+sub process
+{
+ my ($self, $fifo) = @_;
+ my $line = readline($fifo);
+ return unless defined($line);
+ chomp $line;
+ $self->{conn}->privmsg($::settings->{masterchan}, $line);
+}
+
+1;
diff --git a/meta.pl b/meta.pl
index 44eb40f..8ee498d 100755
--- a/meta.pl
+++ b/meta.pl
@@ -27,6 +27,7 @@ use ASM::Log;
use ASM::Commander;
use ASM::Classes;
use ASM::DB;
+use ASM::Fifo;
$Data::Dumper::Useqq=1;
@@ -119,6 +120,7 @@ sub init {
$::commander = ASM::Commander->new();
ASM::Event->new($conn, $::inspector);
$::classes = ASM::Classes->new();
+ $::fifo = ASM::Fifo->new($irc, $conn);
my @strbl = io('string_blacklist.txt')->getlines;
chomp @strbl;
@::string_blacklist = @strbl;