3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

modules/compiler_vm: replace ix.io with 0x0.st for pastes

This commit is contained in:
Pragmatic Software 2021-09-17 13:38:04 -07:00
parent eae16b14b8
commit 347e4ac69f
2 changed files with 29 additions and 2 deletions

View File

@ -25,7 +25,7 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4405,
BUILD_REVISION => 4406,
BUILD_DATE => "2021-09-17",
};

View File

@ -232,7 +232,7 @@ sub show_output {
$pretty_code .= "$output\n";
$pretty_code .= $output_closing_comment;
my $uri = $self->paste_ixio($pretty_code);
my $uri = $self->paste_0x0($pretty_code);
print "$uri\n";
exit 0;
}
@ -289,6 +289,33 @@ sub paste_ixio {
return $result;
}
sub paste_0x0 {
my $self = shift;
my $text = join ' ', @_;
$text =~ s/(.{120})\s/$1\n/g;
my $ua = LWP::UserAgent->new();
$ua->agent("Mozilla/5.0");
push @{ $ua->requests_redirectable }, 'POST';
$ua->timeout(10);
my $response = $ua->post(
"https://0x0.st",
[ file => [ undef, "filename", Content => $text, 'Content-Type' => 'text/plain' ] ],
Content_Type => 'form-data'
);
if(not $response->is_success) {
return "error pasting: " . $response->status_line;
}
my $result = $response->decoded_content;
$result =~ s/^\s+//;
$result =~ s/\s+$//;
return $result;
}
sub execute {
my ($self) = @_;