mirror of
https://github.com/perlbot/perlbuut-pastebin
synced 2025-06-07 06:06:23 -04:00
Merge branch 'master' of github.com:perlbot/perlbuut-pastebin
This commit is contained in:
commit
48acf59c2f
10 changed files with 35 additions and 5 deletions
3
app.cfg
3
app.cfg
|
@ -51,8 +51,11 @@ protocol="perlbot"
|
|||
"192.168.32.1:perlbot:#buubot"="Freenode #buubot"
|
||||
"192.168.32.1:perlbot:#marpa"="Freenode #marpa"
|
||||
"192.168.32.1:perlbot:#cobol"="Freenode #cobol"
|
||||
"192.168.32.1:perlbot:#mojo"="Freenode #mojo"
|
||||
"192.168.32.1:perlbot-magnet:#perl"="irc.perl.org #perl"
|
||||
"192.168.32.1:perlbot-magnet:#perl-help"="irc.perl.org #perl-help"
|
||||
"192.168.32.1:perlbot-magnet:#win32"="irc.perl.org #win32"
|
||||
"192.168.32.1:perlbot-magnet:#toolchain"="irc.perl.org #toolchain"
|
||||
"192.168.32.1:perlbot-oftc:#perl"="OFTC #perl"
|
||||
"192.168.32.1:perlbot-oftc:#perlbot"="OFTC #perlbot"
|
||||
"192.168.32.1:perlbot-efnet:#perl"="EFNet #perl"
|
||||
|
|
1
cpanfile
1
cpanfile
|
@ -9,5 +9,6 @@ requires 'DBD::SQLite';
|
|||
requires 'Mojolicious::Lite';
|
||||
requires 'Mojolicious::Plugin::TtRenderer';
|
||||
requires 'Mojolicious::Plugin::BlogSpam';
|
||||
requires 'Mojolicious::Plugin::RemoteAddr';
|
||||
requires 'App::EvalServerAdvanced::Protocol';
|
||||
requires 'Future::Mojo';
|
||||
|
|
|
@ -22,6 +22,8 @@ sub startup {
|
|||
|
||||
$self->config($cfg->{mojolicious});
|
||||
|
||||
$self->plugin('RemoteAddr');
|
||||
|
||||
$self->plugin('tt_renderer' => {
|
||||
template_options => {
|
||||
PRE_CHOMP => 1,
|
||||
|
|
|
@ -62,7 +62,7 @@ sub api_post_paste {
|
|||
|
||||
my @args = map {($c->param($_))} qw/paste username description channel expire language/;
|
||||
|
||||
my $id = $c->paste->insert_pastebin(@args, $c->tx->remote_address);
|
||||
my $id = $c->paste->insert_pastebin(@args, $c->remote_addr);
|
||||
my ($code, $who, $desc, $channel) = @args;
|
||||
|
||||
# TODO select which one based on config
|
||||
|
@ -73,8 +73,10 @@ sub api_post_paste {
|
|||
# } else {
|
||||
if ($channel) { # TODO config for allowing announcements
|
||||
my $words = $c->paste->banned_word_list_re;
|
||||
unless ($code =~ $words || $who =~ $words || $desc =~ $words || $c->paste->is_banned_ip($c->tx->remote_address)) {
|
||||
$c->perlbot->announce($channel, $who, substr($desc, 0, 40), $c->req->url->base()."/p/$id");
|
||||
my $url = $c->req->url->base()."/p/$id";
|
||||
$url =~ s|http:|https:|;
|
||||
unless ($code =~ $words || $who =~ $words || $desc =~ $words || $c->paste->is_banned_ip($c->remote_addr)) {
|
||||
$c->perlbot->announce($channel, $who, substr($desc, 0, 40), $url);
|
||||
}
|
||||
}
|
||||
# }
|
||||
|
|
|
@ -93,8 +93,10 @@ sub api_post_paste {
|
|||
# } else {
|
||||
if ($channel) { # TODO config for allowing announcements
|
||||
my $words = $c->paste->banned_word_list_re;
|
||||
my $url = $c->req->url->base()."/p/$id";
|
||||
$url =~ s|http:|https:|;
|
||||
unless ($code =~ $words || $who =~ $words || $desc =~ $words || $c->paste->is_banned_ip($c->tx->remote_address)) {
|
||||
$c->perlbot->announce($channel, $who, substr($desc, 0, 40), $c->req->url->base()."/p/$id");
|
||||
$c->perlbot->announce($channel, $who, substr($desc, 0, 40), $url);
|
||||
}
|
||||
}
|
||||
# }
|
||||
|
|
|
@ -5,6 +5,7 @@ use warnings;
|
|||
|
||||
use App::Config;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Mojo::IOLoop;
|
||||
|
||||
sub routes {
|
||||
my ($class, $r) = @_;
|
||||
|
@ -21,6 +22,7 @@ sub routes {
|
|||
$route->(get => '/edit' => 'to_root');
|
||||
|
||||
$route->(get => '/' => 'root');
|
||||
$route->(get => '/headers' => 'headers');
|
||||
$route->(get => '/edit/:pasteid' => 'edit_paste');
|
||||
$route->(get => '/raw/:pasteid' => 'raw_paste');
|
||||
$route->(get => '/pastebin/:pasteid' => 'get_paste');
|
||||
|
@ -110,5 +112,11 @@ sub robots {
|
|||
Disallow: /}, format => 'txt');
|
||||
};
|
||||
|
||||
sub headers {
|
||||
my ($c) = @_;
|
||||
|
||||
use Data::Dumper;
|
||||
$c->render(text => Dumper($c->req));
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -35,7 +35,7 @@ sub get_eval {
|
|||
print "Entering\n";
|
||||
|
||||
if (@$langs == 1 && $langs->[0] eq "evalall") {
|
||||
$langs = [qw/perl perl5.28 perl5.26 perl5.26t perl5.24 perl5.22 perl5.20 perl5.18 perl5.16 perl5.14 perl5.12 perl5.10 perl5.8 perl5.6/];
|
||||
$langs = [qw/perl perl5.28 perl5.26 perl5.26t perl5.24 perl5.22 perl5.20 perl5.18 perl5.16 perl5.14 perl5.12 perl5.10 perl5.8 perl5.6 perl5.8.8 perl5.10.0/];
|
||||
}
|
||||
|
||||
use Data::Dumper;
|
||||
|
@ -103,6 +103,9 @@ sub async_eval {
|
|||
|
||||
my $seq = $id++;
|
||||
|
||||
# try to fix bash?
|
||||
$code =~ s/\r//g;
|
||||
|
||||
$self->_adopt_future($seq, $future);
|
||||
my $eval_obj = {language => $lang,
|
||||
files => [
|
||||
|
|
|
@ -8,6 +8,7 @@ use Mojo::Base '-base';
|
|||
my @langs = (
|
||||
{name => "perl5.28", mode => "perl", description => "Perl 5.28"},
|
||||
{name => "perl6", mode => "perl", description => "Rakudo Star / Perl 6"},
|
||||
{name => "bash", mode => "bash", description => "Bash"},
|
||||
{name => "ruby", mode => "ruby", description => "Ruby (2.1)"},
|
||||
{name => "javascript", mode => "javascript", description => "Javascript/Node.js"},
|
||||
{name => "tcc", mode => "c_cpp", description => "TCC 0.9.27"},
|
||||
|
@ -40,6 +41,8 @@ my @langs = (
|
|||
{name => "perl2", mode => "perl", description => "Perl 2"},
|
||||
{name => "perl1", mode => "perl", description => "Perl 1"},
|
||||
{name => "cperl", mode => "perl", description => "CPerl 5.26"},
|
||||
{name => "perl5.8.8", mode => "perl", description => "Perl 5.8.8 (Known bugs)"},
|
||||
{name => "perl5.10.0", mode => "perl", description => "Perl 5.10.0 (Known bugs)"},
|
||||
|
||||
);
|
||||
|
||||
|
|
|
@ -13,9 +13,11 @@ sub announce {
|
|||
my $self = shift;
|
||||
my ($channel, $who, $what, $link) = @_;
|
||||
|
||||
printf "Sending to %s:%s = %s\n", $self->config->{host}, $self->config->{port}, "$channel\x1E$link\x1E$who\x1E$what\n";
|
||||
my $socket = IO::Socket::INET->new( PeerAddr => $self->config->{host}, PeerPort => $self->config->{port} )
|
||||
or die "error: cannot connect to announce server: $! ".$self->config->{host} . ":" .$self->config->{port};
|
||||
|
||||
|
||||
print $socket "$channel\x1E$link\x1E$who\x1E$what\n";
|
||||
close($socket);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
"magnet.perl.bot": "192.168.32.1:perlbot-magnet:",
|
||||
"o.perl.bot": "192.168.32.1:perlbot-oftc:",
|
||||
"oftc.perl.bot": "192.168.32.1:perlbot-oftc:",
|
||||
"e.perl.bot": "192.168.32.1:perlbot-efnet",
|
||||
"efnet.perl.bot": "192.168.32.1:perlbot-efnet",
|
||||
"e.perlbot.pl": "192.168.32.1:perlbot-efnet",
|
||||
"efnet.perlbot.pl": "192.168.32.1:perlbot-efnet",
|
||||
};
|
||||
|
||||
if (channel && servers[hostname]) { // only do this if we have a channel and a valid server
|
||||
|
|
Loading…
Add table
Reference in a new issue