mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-29 15:29:32 +01:00
compiler_vm: Add $channel argument to separate snippet history into per-channel/nick files
This commit is contained in:
parent
921c9917a5
commit
a5ae7478e1
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 502,
|
||||
BUILD_REVISION => 503,
|
||||
BUILD_DATE => "2014-03-04",
|
||||
};
|
||||
|
||||
|
@ -1851,10 +1851,10 @@ action: /say C89/C90 draft: http://flash-gordon.me.uk/ansi.c.txt or http://web.a
|
||||
created_on: 1236861685
|
||||
enabled: 1
|
||||
last_referenced_in: pragma-
|
||||
last_referenced_on: 1393877069.42851
|
||||
last_referenced_on: 1393946502.21155
|
||||
owner: Wulf4
|
||||
rate_limit: 15
|
||||
ref_count: 97
|
||||
ref_count: 98
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
@ -7185,34 +7185,34 @@ action_with_args: /say $nick, $answers
|
||||
created_on: 1193948417
|
||||
enabled: 1
|
||||
last_referenced_in: ##c
|
||||
last_referenced_on: 1393901895.20933
|
||||
last_referenced_on: 1393945309.2847
|
||||
owner: pragma_
|
||||
rate_limit: 0
|
||||
ref_count: 1303
|
||||
ref_user: puish!~jgb@unaffiliated/jonbryan
|
||||
ref_count: 1304
|
||||
ref_user: cousteau!~cousteau@138.100.74.81
|
||||
type: text
|
||||
|
||||
<:(>
|
||||
action: /call :)
|
||||
created_on: 1180052710
|
||||
enabled: 1
|
||||
last_referenced_on: 1390399438.41235
|
||||
last_referenced_on: 1393961635.61896
|
||||
owner: pragma_
|
||||
rate_limit: 15
|
||||
ref_count: 27
|
||||
ref_user: rie!~chatzilla@p2003004ACE51B43792E6BAFFFE5389F3.dip0.t-ipconnect.de
|
||||
ref_count: 28
|
||||
ref_user: nCrazed!~nCrazed@5.2.16.190
|
||||
type: text
|
||||
|
||||
<:)>
|
||||
action: /say $faces
|
||||
created_on: 1109365121
|
||||
enabled: 1
|
||||
last_referenced_in: rob``
|
||||
last_referenced_on: 1390851212.03434
|
||||
last_referenced_in: ##c
|
||||
last_referenced_on: 1393961635.63607
|
||||
owner: pragma_
|
||||
rate_limit: 15
|
||||
ref_count: 152
|
||||
ref_user: rob``!~rob@gtng-4db047dd.pool.mediaWays.net
|
||||
ref_count: 153
|
||||
ref_user: nCrazed!~nCrazed@5.2.16.190
|
||||
type: text
|
||||
|
||||
<:-(>
|
||||
@ -8557,11 +8557,11 @@ type: text
|
||||
action: c11std.pl
|
||||
created_on: 1326727233.54048
|
||||
enabled: 1
|
||||
last_referenced_in: ##c
|
||||
last_referenced_on: 1393889491.09541
|
||||
last_referenced_in: pragma-
|
||||
last_referenced_on: 1393959075.38608
|
||||
owner: pragma_
|
||||
rate_limit: 0
|
||||
ref_count: 1136
|
||||
ref_count: 1141
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: module
|
||||
|
||||
@ -8703,14 +8703,16 @@ ref_user: pragma_
|
||||
type: text
|
||||
|
||||
<cc>
|
||||
action: /call compiler $nick
|
||||
action: /call compiler $nick $channel
|
||||
created_on: 1272176634
|
||||
edited_by: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
edited_on: 1393967703.12375
|
||||
enabled: 1
|
||||
last_referenced_on: 1393921443.89722
|
||||
last_referenced_on: 1393967711.47421
|
||||
owner: pragma_
|
||||
preserve_whitespace: 1
|
||||
rate_limit: 4
|
||||
ref_count: 37728
|
||||
ref_count: 37763
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
@ -8764,10 +8766,10 @@ type: text
|
||||
action: /call factchange
|
||||
created_on: 1277259441.33026
|
||||
enabled: 1
|
||||
last_referenced_on: 1393300207.62137
|
||||
last_referenced_on: 1393967703.11071
|
||||
owner: pbot3
|
||||
rate_limit: 15
|
||||
ref_count: 236
|
||||
ref_count: 238
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
@ -8972,10 +8974,10 @@ action: compiler_client.pl
|
||||
created_on: 1291939583.25391
|
||||
enabled: 1
|
||||
last_referenced_in: pragma-
|
||||
last_referenced_on: 1393921443.9184
|
||||
last_referenced_on: 1393967711.49546
|
||||
owner: pragma_
|
||||
rate_limit: 0
|
||||
ref_count: 30569
|
||||
ref_count: 30604
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: module
|
||||
|
||||
@ -9637,11 +9639,11 @@ type: text
|
||||
action: /call factfind
|
||||
created_on: 1277784994.65625
|
||||
enabled: 1
|
||||
last_referenced_on: 1393744259.21007
|
||||
last_referenced_on: 1393951484.46497
|
||||
owner: pbot3
|
||||
rate_limit: 15
|
||||
ref_count: 358
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
ref_count: 359
|
||||
ref_user: lemonade`!~lemonade`@pool-108-28-100-56.washdc.fios.verizon.net
|
||||
type: text
|
||||
|
||||
<floating>
|
||||
@ -10125,12 +10127,12 @@ action: /say To learn all about me, see http://www.iso-9899.info/wiki/Candide
|
||||
action_with_args: /say To learn all about $args, see http://www.iso-9899.info/wiki/Candide#$args
|
||||
created_on: 1109792986
|
||||
enabled: 1
|
||||
last_referenced_in: lemonade`
|
||||
last_referenced_on: 1393639199.45894
|
||||
last_referenced_in: ##c
|
||||
last_referenced_on: 1393933113.36018
|
||||
owner: NeverDream
|
||||
rate_limit: 0
|
||||
ref_count: 1224
|
||||
ref_user: lemonade`!~lemonade`@pool-108-28-100-56.washdc.fios.verizon.net
|
||||
ref_count: 1226
|
||||
ref_user: dozn!~dozn@24-207-52-240.eastlink.ca
|
||||
type: text
|
||||
|
||||
<herring>
|
||||
@ -11010,12 +11012,12 @@ type: text
|
||||
action: man.pl
|
||||
created_on: 1107137901
|
||||
enabled: 1
|
||||
last_referenced_in: puish
|
||||
last_referenced_on: 1393565259.68701
|
||||
last_referenced_in: ##c
|
||||
last_referenced_on: 1393945292.18739
|
||||
owner: pragma_
|
||||
rate_limit: 15
|
||||
ref_count: 1361
|
||||
ref_user: puish!~jgb@unaffiliated/jonbryan
|
||||
ref_count: 1362
|
||||
ref_user: cousteau!~cousteau@138.100.74.81
|
||||
type: module
|
||||
|
||||
<manpage>
|
||||
@ -12290,12 +12292,12 @@ type: text
|
||||
action: /say $args
|
||||
created_on: 1251663502
|
||||
enabled: 1
|
||||
last_referenced_in: ##c
|
||||
last_referenced_on: 1393702026.66878
|
||||
last_referenced_in: pragma-
|
||||
last_referenced_on: 1393967745.99187
|
||||
owner: pragma_
|
||||
rate_limit: 0
|
||||
ref_count: 808
|
||||
ref_user: fisted!~fisted@unaffiliated/fisted
|
||||
ref_count: 814
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
<scheme>
|
||||
@ -12459,10 +12461,10 @@ type: regex
|
||||
action: /call factshow
|
||||
created_on: 1277259146.86343
|
||||
enabled: 1
|
||||
last_referenced_on: 1393928620.05921
|
||||
last_referenced_on: 1393967768.1747
|
||||
owner: pbot3
|
||||
rate_limit: 15
|
||||
ref_count: 186
|
||||
ref_count: 194
|
||||
ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
@ -12933,11 +12935,11 @@ type: text
|
||||
action: /call 8ball
|
||||
created_on: 1360662740.86483
|
||||
enabled: 1
|
||||
last_referenced_on: 1389897389.91006
|
||||
last_referenced_on: 1393945309.26443
|
||||
owner: pragma-
|
||||
rate_limit: 15
|
||||
ref_count: 2
|
||||
ref_user: zid`!zid@laiz.stalker.fi
|
||||
ref_count: 3
|
||||
ref_user: cousteau!~cousteau@138.100.74.81
|
||||
type: text
|
||||
|
||||
<that's>
|
||||
@ -13398,8 +13400,8 @@ ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
<version>
|
||||
action: /say PBot revision 494 2014-03-01
|
||||
created_on: 1393838096.62111
|
||||
action: /say PBot revision 501 2014-03-04
|
||||
created_on: 1393968046.58128
|
||||
enabled: 1
|
||||
last_referenced_in: lemonade`
|
||||
last_referenced_on: 1393639215.26177
|
||||
@ -13940,8 +13942,10 @@ ref_user: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
type: text
|
||||
|
||||
<{>
|
||||
action: /call compiler_block $nick
|
||||
action: /call compiler_block $nick $channel
|
||||
created_on: 1329860884.76944
|
||||
edited_by: pragma-!~chaos@unaffiliated/pragmatic-chaos
|
||||
edited_on: 1393967624.45297
|
||||
enabled: 1
|
||||
last_referenced_in: pragma_
|
||||
last_referenced_on: 1393297892.74508
|
||||
|
@ -21,6 +21,7 @@ if(not defined $sock) {
|
||||
}
|
||||
|
||||
my $nick = shift @ARGV;
|
||||
my $channel = shift @ARGV;
|
||||
my $code = join ' ', @ARGV;
|
||||
|
||||
#$code = "{ $code";
|
||||
@ -32,7 +33,7 @@ if($code =~ s/-lang=([^ ]+)//) {
|
||||
$lang = uc $1;
|
||||
}
|
||||
|
||||
print $sock "compile:$nick:$lang\n";
|
||||
print $sock "compile:$nick:$channel:$lang\n";
|
||||
print $sock "$code\n";
|
||||
print $sock "compile:end\n";
|
||||
|
||||
|
@ -21,6 +21,7 @@ if(not defined $sock) {
|
||||
}
|
||||
|
||||
my $nick = shift @ARGV;
|
||||
my $channel = shift @ARGV;
|
||||
my $code = join ' ', @ARGV;
|
||||
|
||||
my $lang = "C11";
|
||||
@ -29,7 +30,7 @@ if($code =~ s/-lang=([^ ]+)//) {
|
||||
$lang = uc $1;
|
||||
}
|
||||
|
||||
print $sock "compile:$nick:$lang\n";
|
||||
print $sock "compile:$nick:$channel:$lang\n";
|
||||
print $sock "$code\n";
|
||||
print $sock "compile:end\n";
|
||||
|
||||
|
@ -178,6 +178,7 @@ sub compiler_server {
|
||||
eval {
|
||||
my $lang;
|
||||
my $nick;
|
||||
my $channel;
|
||||
my $code = "";
|
||||
|
||||
local $SIG{ALRM} = sub { die 'Timed-out'; };
|
||||
@ -196,13 +197,10 @@ sub compiler_server {
|
||||
last;
|
||||
}
|
||||
|
||||
$code = quotemeta($code);
|
||||
print "Attempting compile...\n";
|
||||
alarm 0;
|
||||
my $tnick = quotemeta($nick);
|
||||
my $tlang = quotemeta($lang);
|
||||
|
||||
my ($ret, $result) = execute("./compiler_vm_client.pl $tnick -lang=$tlang $code");
|
||||
my ($ret, $result) = execute("./compiler_vm_client.pl \Q$nick\E \Q$channel\E -lang=\Q$lang\E \Q$code\E");
|
||||
|
||||
if(not defined $ret) {
|
||||
#print "parent continued\n";
|
||||
@ -234,9 +232,10 @@ sub compiler_server {
|
||||
exit $ret;
|
||||
}
|
||||
|
||||
if($line =~ /compile:([^:]+):(.*)$/) {
|
||||
if($line =~ /compile:([^:]+):([^:]+):(.*)$/) {
|
||||
$nick = $1;
|
||||
$lang = $2;
|
||||
$channel = $2;
|
||||
$lang = $3;
|
||||
$code = "";
|
||||
next;
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ my %languages = (
|
||||
);
|
||||
|
||||
my %preludes = (
|
||||
'C99' => "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <stdbool.h>\n#include <stddef.h>\n#include <stdarg.h>\n#include <ctype.h>\n#include <inttypes.h>\n#include <float.h>\n#include <errno.h>\n#include <time.h>\n#include <assert.h>\n#include <prelude.h>\n\n",
|
||||
'C11' => "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <stdbool.h>\n#include <stddef.h>\n#include <stdarg.h>\n#include <stdnoreturn.h>\n#include <stdalign.h>\n#include <ctype.h>\n#include <inttypes.h>\n#include <float.h>\n#include <errno.h>\n#include <time.h>\n#include <assert.h>\n#include <complex.h>\n#include <prelude.h>\n\n",
|
||||
'C89' => "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <errno.h>\n#include <ctype.h>\n#include <assert.h>\n#include <prelude.h>\n\n",
|
||||
'C99' => "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <stdbool.h>\n#include <stddef.h>\n#include <stdarg.h>\n#include <ctype.h>\n#include <inttypes.h>\n#include <float.h>\n#include <errno.h>\n#include <time.h>\n#include <assert.h>\n#include <signal.h>\n#include <prelude.h>\n\n",
|
||||
'C11' => "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <stdbool.h>\n#include <stddef.h>\n#include <stdarg.h>\n#include <stdnoreturn.h>\n#include <stdalign.h>\n#include <ctype.h>\n#include <inttypes.h>\n#include <float.h>\n#include <errno.h>\n#include <time.h>\n#include <assert.h>\n#include <complex.h>\n#include <signal.h>\n#include <prelude.h>\n\n",
|
||||
'C89' => "#define _XOPEN_SOURCE 9001\n#define __USE_XOPEN\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <math.h>\n#include <limits.h>\n#include <sys/types.h>\n#include <stdint.h>\n#include <errno.h>\n#include <ctype.h>\n#include <assert.h>\n#include <signal.h>\n#include <prelude.h>\n\n",
|
||||
);
|
||||
|
||||
sub pretty {
|
||||
@ -139,18 +139,20 @@ sub compile {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if($#ARGV < 1) {
|
||||
if($#ARGV < 2) {
|
||||
print "Usage: cc [-compiler -options] <code> [-stdin=input]\n";
|
||||
# usage for shell: cc <nick> <channel> [-compiler -options] <code> [-stdin=input]
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $nick = shift @ARGV;
|
||||
my $channel = lc shift @ARGV;
|
||||
my $code = join ' ', @ARGV;
|
||||
my @last_code;
|
||||
|
||||
print " code: [$code]\n" if $debug;
|
||||
|
||||
if(open FILE, "< last_code.txt") {
|
||||
if(open FILE, "< history/$channel.hist") {
|
||||
while(my $line = <FILE>) {
|
||||
chomp $line;
|
||||
push @last_code, $line;
|
||||
@ -598,7 +600,7 @@ if($save_last_code) {
|
||||
unshift @last_code, $extracted_args . (length $args ? $args . ' ' . $code : $code);
|
||||
}
|
||||
|
||||
open FILE, "> last_code.txt";
|
||||
open FILE, "> history/$channel.hist";
|
||||
|
||||
my $i = 0;
|
||||
foreach my $line (@last_code) {
|
||||
|
Loading…
Reference in New Issue
Block a user