mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Added dice_roll.pl module, and updated others
This commit is contained in:
parent
bf91c67346
commit
65660625c2
@ -13,7 +13,7 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 384,
|
BUILD_REVISION => 385,
|
||||||
BUILD_DATE => "2012-09-17",
|
BUILD_DATE => "2012-09-17",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
43
modules/compiler_block.pl
Executable file
43
modules/compiler_block.pl
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# compiler_client.pl connects to compiler_server.pl hosted at PeerAddr/PeerPort below
|
||||||
|
# and sends a nick, language and code, then retreives and prints the compilation/execution output.
|
||||||
|
#
|
||||||
|
# this way we can run the compiler virtual machine on any remote server.
|
||||||
|
|
||||||
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use IO::Socket;
|
||||||
|
|
||||||
|
my $sock = IO::Socket::INET->new(
|
||||||
|
PeerAddr => '192.168.0.42',
|
||||||
|
PeerPort => 9000,
|
||||||
|
Proto => 'tcp');
|
||||||
|
|
||||||
|
if(not defined $sock) {
|
||||||
|
print "Fatal error compiling: $!; try the cc2 command instead\n";
|
||||||
|
die $!;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $nick = shift @ARGV;
|
||||||
|
my $code = join ' ', @ARGV;
|
||||||
|
|
||||||
|
#$code = "{ $code";
|
||||||
|
$code =~ s/\s*}\s*$//;
|
||||||
|
|
||||||
|
my $lang = "C11";
|
||||||
|
|
||||||
|
if($code =~ s/-lang=([^ ]+)//) {
|
||||||
|
$lang = uc $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
print $sock "compile:$nick:$lang\n";
|
||||||
|
print $sock "$code\n";
|
||||||
|
print $sock "compile:end\n";
|
||||||
|
|
||||||
|
while(my $line = <$sock>) {
|
||||||
|
print "$line";
|
||||||
|
}
|
||||||
|
|
||||||
|
close $sock;
|
41
modules/dice_roll.pl
Executable file
41
modules/dice_roll.pl
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
|
||||||
|
|
||||||
|
# quick and dirty by :pragma
|
||||||
|
|
||||||
|
use Games::Dice qw/roll roll_array/;
|
||||||
|
|
||||||
|
my ($result, $rolls, $show);
|
||||||
|
|
||||||
|
if ($#ARGV <0)
|
||||||
|
{
|
||||||
|
print "Usage: roll [-show] <dice roll>; e.g.: roll 3d6+1. To see all individual dice rolls, add -show.\n";
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rolls = join("", @ARGV);
|
||||||
|
|
||||||
|
if($rolls =~ s/\s*-show\s*//) {
|
||||||
|
$show = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($rolls =~ m/^\s*(\d+)d\d+\s*$/) {
|
||||||
|
if($1 > 100) {
|
||||||
|
print "Sorry, maximum of 100 rolls.\n";
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "Usage: roll [-show] <dice roll>; e.g.: roll 3d6+1. To see all individual dice rolls, add -show.\n";
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($show) {
|
||||||
|
my @results = roll_array $rolls;
|
||||||
|
$result = 0;
|
||||||
|
foreach my $n (@results) {
|
||||||
|
$result += $n;
|
||||||
|
}
|
||||||
|
print "/me rolled $rolls for @results totaling $result.\n";
|
||||||
|
} else {
|
||||||
|
$result = roll $rolls;
|
||||||
|
print "/me rolled $rolls for $result.\n";
|
||||||
|
}
|
@ -26,6 +26,7 @@ exit if($arguments =~ m/github.com/i);
|
|||||||
exit if($arguments =~ m/wiki.osdev.org/i);
|
exit if($arguments =~ m/wiki.osdev.org/i);
|
||||||
exit if($arguments =~ m/wikipedia.org/i);
|
exit if($arguments =~ m/wikipedia.org/i);
|
||||||
exit if($arguments =~ m/everfall.com/i);
|
exit if($arguments =~ m/everfall.com/i);
|
||||||
|
exit if($arguments =~ m/fukung.net/i);
|
||||||
exit if($arguments =~ m/\/paste\//i);
|
exit if($arguments =~ m/\/paste\//i);
|
||||||
exit if($arguments =~ m/paste\./i);
|
exit if($arguments =~ m/paste\./i);
|
||||||
exit if($arguments =~ m/pastie/i);
|
exit if($arguments =~ m/pastie/i);
|
||||||
|
Loading…
Reference in New Issue
Block a user