diff --git a/bin/setup-netns.sh b/bin/setup-netns.sh new file mode 100755 index 0000000..8b4c330 --- /dev/null +++ b/bin/setup-netns.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e +set -u + +ip netns delete perlbot >& /dev/null && echo "Removed old perlbot namespace" || echo "No perlbot namespace yet" +ip link delete perlbot-public type veth >& /dev/null && echo "Removed old perlbot veth device" || echo "No perlbot veth device yet" + +ip netns add perlbot +ip link add perlbot-private type veth peer name perlbot-public +ip link set perlbot-private netns perlbot + +sleep 1 + +ip addr add 192.168.196.1/24 dev perlbot-public +ip link set perlbot-public up + +ip netns exec perlbot ip link set dev lo up +ip netns exec perlbot ip addr add 192.168.196.2/24 dev perlbot-private +ip netns exec perlbot ip link set perlbot-private up +ip netns exec perlbot ip route add default via 192.168.196.1 + +iptables -N PERLBOT-FORWARD || iptables -F PERLBOT-FORWARD +iptables -t nat -N PERLBOT-POST || iptables -t nat -F PERLBOT-POST + +iptables -A PERLBOT-FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT +iptables -A PERLBOT-FORWARD -i perlbot-public -d 192.168.32.1 -j ACCEPT +iptables -A PERLBOT-FORWARD -i perlbot-public -d 192.168.196.0/24 -j ACCEPT +iptables -A PERLBOT-FORWARD -i perlbot-public -d 192.168.0.0/16 -j REJECT +iptables -A PERLBOT-FORWARD -i perlbot-public -d 10.0.0.0/8 -j REJECT +#iptables -t nat -A PERLBOT-POST -s 192.168.196.0/24 -d 192.168.196.0/24 -j ACCEPT +#iptables -t nat -A PERLBOT-POST -s 192.168.196.0/24 -o perlbot-public -j MASQUERADE + +iptables -t filter -D FORWARD -j PERLBOT-FORWARD || echo "No filter chain loaded" +#iptables -t nat -D POSTROUTING -j PERLBOT-POST || echo "No nat chain loaded" +#iptables -t nat -A POSTROUTING -j PERLBOT-POST +iptables -t filter -I FORWARD 1 -j PERLBOT-FORWARD diff --git a/cpanfile b/cpanfile index f8b08a4..2c115fd 100644 --- a/cpanfile +++ b/cpanfile @@ -118,7 +118,7 @@ requires 'Task::Kensho::Logging'; requires 'Task::Kensho::ModuleDev'; requires 'Task::Kensho::OOP'; #requires 'Task::Kensho::Testing'; -requires 'Task::Kensho::XML'; +#requires 'Task::Kensho::XML'; requires 'Text::Unidecode'; requires 'experimental'; @@ -127,3 +127,18 @@ requires 'Math::Calc::Parser'; requires 'ReadonlyX'; requires 'Const::Fast'; requires 'DateTime::Event::Holiday::US'; +requires 'App::EvalServerAdvanced::ConstantCalc'; + +requires 'Crypt::OpenSSL::X509'; + +requires 'Math::Random::Secure'; # undeclared dep of Data::Random::Flexible +requires 'Data::Random::Flexible'; +requires 'Acme::AsciiEmoji'; +requires 'PadWalker'; +requires 'Encode::Simple'; +requires 'PPR'; +requires 'Keyword::Simple'; +requires 'Unicode::UTF8'; +requires 'List::Gather'; +requires 'Lingua::EN::Inflexion'; +requires 'local::lib'; diff --git a/etc/plugins.conf b/etc/plugins.conf index a6a969b..8810e6e 100644 --- a/etc/plugins.conf +++ b/etc/plugins.conf @@ -17,6 +17,9 @@ server "*" { plugin "eval" {addressed: false; } plugin "deparse" {addressed: false; } } + channel "#perl6" { + plugin "eval" {addressed: false; } + } channel "#perl-help" { plugin "eval" {addressed: false; } plugin "deparse" {addressed: false; } diff --git a/lib/Bot/BB3/Roles/Evalpastebin.pm b/lib/Bot/BB3/Roles/Evalpastebin.pm index 80fa7b9..6b159ab 100644 --- a/lib/Bot/BB3/Roles/Evalpastebin.pm +++ b/lib/Bot/BB3/Roles/Evalpastebin.pm @@ -50,7 +50,7 @@ sub _start { # TODO setup TCP server. $self->{server} = POE::Component::Server::TCP->new( Port => 1784, - Address =>'127.0.0.1', + Address =>'192.168.196.2', ClientFilter => "POE::Filter::Line", ClientInput => \&receive_paste, ); diff --git a/plugins/factoids.pm b/plugins/factoids.pm index dca1770..9f3a083 100644 --- a/plugins/factoids.pm +++ b/plugins/factoids.pm @@ -276,6 +276,9 @@ sub handle { my ($self, $said, $pm) = @_; my $conf = $self->get_conf_for_channel($pm, $said->{server}, $said->{channel}); + + $said->{body} =~ s/^\s*(what|who|where|how|when|why)\s+($COPULA_RE)\s+(?.*?)\??\s*$/$+{fact}/i; + my $prefix = $conf->{prefix_command}; return unless $prefix; diff --git a/plugins/get.pm b/plugins/get.pm index 843ab6f..76d01e2 100644 --- a/plugins/get.pm +++ b/plugins/get.pm @@ -1,4 +1,3 @@ -use Net::INET6Glue::INET_is_INET6; use LWP::UserAgent; use HTML::TreeBuilder::XPath; @@ -21,6 +20,7 @@ sub { my $ua = LWP::UserAgent->new( agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" ); my $url; + if( $said->{body} =~ s{(https?://\S+)\s*}{} ) { $url = $1; } @@ -32,7 +32,6 @@ sub { return; } - my $resp = $ua->get( $url ); if( not $resp ) { @@ -40,27 +39,27 @@ sub { return; } - my @text; - my $document = HTML::TreeBuilder::XPath->new_from_content( $resp->content ); - if (!$document) { - print "Could not parsinate that page!"; - } - # just the xpath left - if ($said->{body} =~ /^\s*\.\*\s*$/) { - print $resp->content; - } elsif ($said->{body}) { - @text = eval{ - $document->findvalues( $said->{body} ); - }; - @text = "Your Xpath didn't match anything" if 0 == @text; - @text = "Your Xpath fails: $@" if $@; - } - if (! $said->{body} ){ - @text = ($@,$document->findvalues( '//title' ), ': ',$document->findvalues( '//body' )); - } - local $, = ', '; - - print map { local $_ = "$_"; s/\s+/ /g;s/^ +//; s/ +$//; $_} @text + my @text; + my $document = HTML::TreeBuilder::XPath->new_from_content( $resp->content ); + if (!$document) { + print "Could not parsinate that page!"; + } + # just the xpath left + if ($said->{body} =~ /^\s*\.\*\s*$/) { + print $resp->content; + } elsif ($said->{body}) { + @text = eval{ + $document->findvalues( $said->{body} ); + }; + @text = "Your Xpath didn't match anything" if 0 == @text; + @text = "Your Xpath fails: $@" if $@; + } + if (! $said->{body} ){ + @text = ($@,$document->findvalues( '//title' ), ': ',$document->findvalues( '//body' )); + } + local $, = ', '; + + print map { local $_ = "$_"; s/\s+/ /g;s/^ +//; s/ +$//; $_} @text } __DATA__ diff --git a/plugins/pastebinadmin.pm b/plugins/pastebinadmin.pm index d35e746..12b0b6b 100644 --- a/plugins/pastebinadmin.pm +++ b/plugins/pastebinadmin.pm @@ -109,7 +109,7 @@ sub command { } elsif ($command eq 'banuser') { my $paste = $args[0]; - if (my ($id) = ($paste =~ m{^(?:(?:https?://(?:[a-z\.]+)?perlbot.pl/p(?:astebin)?/([^/]{6,})/?)|([^/]+))$}g)) { + if (my ($id) = ($paste =~ m{^(?:(?:https?://(?:[a-z\.]+)?(?:perlbot\.pl|perl\.bot)/p(?:astebin)?/([^/]{6,})/?)|([^/]+))$}g)) { my $response = $self->ban_user_paste($env, $id, $who, $where); return ("handled", $response); } else { diff --git a/plugins/supereval.pm b/plugins/supereval.pm index b387588..60471a4 100644 --- a/plugins/supereval.pm +++ b/plugins/supereval.pm @@ -36,9 +36,7 @@ sub make_pastebin { } } - - -my @versions = ('', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.8 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 all)); +my @versions = ('', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.6t 5.8 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.26t all)); sub new { my( $class ) = @_; @@ -205,7 +203,9 @@ sub command { if (rand() < $special{$holiday}{prob}) { my $char = $special{$holiday}{chars}[rand()*@{$special{$holiday}{chars}}]; - $resultstr .= " ".$char; + unless ($said->{nested}) { # if we're called in compose don't do this + $resultstr .= " ".$char; # disabled until i make it magic-erer + } } }