From 65660625c2256a810e4c8a04cd14c5f5cf279e24 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 18 Sep 2012 01:32:07 +0000 Subject: [PATCH] Added dice_roll.pl module, and updated others --- PBot/VERSION.pm | 2 +- modules/compiler_block.pl | 43 +++++++++++++++++++++++++++++++++++++++ modules/dice_roll.pl | 41 +++++++++++++++++++++++++++++++++++++ modules/get_title.pl | 1 + 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100755 modules/compiler_block.pl create mode 100755 modules/dice_roll.pl diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 7194355a..757f7109 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 384, + BUILD_REVISION => 385, BUILD_DATE => "2012-09-17", }; diff --git a/modules/compiler_block.pl b/modules/compiler_block.pl new file mode 100755 index 00000000..aaf88914 --- /dev/null +++ b/modules/compiler_block.pl @@ -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; diff --git a/modules/dice_roll.pl b/modules/dice_roll.pl new file mode 100755 index 00000000..8eec7231 --- /dev/null +++ b/modules/dice_roll.pl @@ -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] ; 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] ; 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"; +} diff --git a/modules/get_title.pl b/modules/get_title.pl index 2de6dc81..c5a445da 100755 --- a/modules/get_title.pl +++ b/modules/get_title.pl @@ -26,6 +26,7 @@ exit if($arguments =~ m/github.com/i); exit if($arguments =~ m/wiki.osdev.org/i); exit if($arguments =~ m/wikipedia.org/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/pastie/i);