3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-19 10:29:30 +01:00

compiler_vm: update vm-client

This commit is contained in:
Pragmatic Software 2022-01-29 19:23:36 -08:00
parent fbb74bbca3
commit a5e5dd5533

View File

@ -18,11 +18,12 @@ use warnings;
use strict; use strict;
use IO::Socket; use IO::Socket;
use JSON;
my $sock = IO::Socket::INET->new( my $sock = IO::Socket::INET->new(
PeerAddr => '127.0.0.1', PeerAddr => '127.0.0.1',
PeerPort => 9000, PeerPort => 9000,
Proto => 'tcp', Proto => 'tcp'
); );
if (not defined $sock) { if (not defined $sock) {
@ -30,22 +31,18 @@ if (not defined $sock) {
die $!; die $!;
} }
my $nick = shift @ARGV; my $json = join ' ', @ARGV;
my $channel = shift @ARGV; my $h = decode_json $json;
my $code = join '', @ARGV;
my $lang = "c11"; my $lang = $h->{lang} // "c11";
if ($code =~ s/-lang=([^ ]+)//) { if ($h->{code} =~ s/-lang=([^ ]+)//) { $lang = lc $1; }
$lang = lc $1;
}
print $sock "compile:$nick:$channel:$lang\n"; $h->{lang} = $lang;
print $sock "$code\n"; $json = encode_json $h;
print $sock "compile:end\n";
while (my $line = <$sock>) { print $sock "$json\n";
print "$line";
} while (my $line = <$sock>) { print "$line"; }
close $sock; close $sock;