From c0d8cffbe266f8d228c8247007765592541c0517 Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Mon, 24 Apr 2017 21:04:53 -0400 Subject: [PATCH] Language works on eval now --- lib/App/Controller/Paste.pm | 2 +- lib/App/Model/Eval.pm | 5 ++++- lib/App/Model/Perlbot.pm | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/App/Controller/Paste.pm b/lib/App/Controller/Paste.pm index fec22d5..b48d6db 100644 --- a/lib/App/Controller/Paste.pm +++ b/lib/App/Controller/Paste.pm @@ -101,7 +101,7 @@ sub get_paste { if ($row) { $c->stash($row); $c->stash({page_tmpl => 'viewer.html'}); - $c->stash({eval => $c->eval->get_eval($pasteid, $row->{paste}, $row->{lang})}); + $c->stash({eval => $c->eval->get_eval($pasteid, $row->{paste}, $row->{language})}); $c->stash({paste_id => $pasteid}); $c->render('page'); diff --git a/lib/App/Model/Eval.pm b/lib/App/Model/Eval.pm index 4f18b6a..d52d609 100644 --- a/lib/App/Model/Eval.pm +++ b/lib/App/Model/Eval.pm @@ -24,7 +24,10 @@ sub get_eval { my $socket = IO::Socket::INET->new( PeerAddr => $self->cfg->{server} //'localhost', PeerPort => $self->cfg->{port} //14400 ) or die "error: cannot connect to eval server"; - my $refs = $filter->put( [ { code => "perl $code" } ] ); # TODO make this support other langs + $lang //= "perl"; + return undef if ($lang eq 'text'); + + my $refs = $filter->put( [ { code => $lang . " $code" } ] ); print $socket $refs->[0]; my $output = do {local $/; <$socket>}; diff --git a/lib/App/Model/Perlbot.pm b/lib/App/Model/Perlbot.pm index 66ea449..44763a5 100644 --- a/lib/App/Model/Perlbot.pm +++ b/lib/App/Model/Perlbot.pm @@ -13,7 +13,7 @@ sub announce { my $self = shift; my ($channel, $who, $what, $link) = @_; - my $socket = IO::Socket::INET->new( PeerAddr => $self->config->{server} //'localhost', PeerPort => $self->cfg->{port} //1784 ) + my $socket = IO::Socket::INET->new( PeerAddr => $self->config->{server} //'localhost', PeerPort => $self->config->{port} //1784 ) or die "error: cannot connect to announce server"; print $socket "$channel\x1E$link\x1E$who\x1E$what\n";