3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-30 07:59:42 +01:00

Paste to ix.io instead of sprunge; set 10 second timeout for pastes

This commit is contained in:
Pragmatic Software 2017-10-05 14:31:58 -07:00
parent 8ba0664b85
commit f07c34f53f

View File

@ -492,7 +492,7 @@ sub paste {
my $text = join(' ', @_);
$text =~ s/(.{120})\s/$1\n/g;
my $result = $self->paste_sprunge($text);
my $result = $self->paste_ixio($text);
if ($result =~ m/error pasting/) {
$result = $self->paste_codepad($text);
@ -501,6 +501,33 @@ sub paste {
return $result;
}
sub paste_ixio {
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 %post = ('f:1' => $text);
my $response = $ua->post("http://ix.io", \%post);
use Data::Dumper;
print Dumper $response;
if(not $response->is_success) {
return "error pasting: " . $response->status_line;
}
my $result = $response->content;
$result =~ s/^\s+//;
$result =~ s/\s+$//;
return $result;
}
sub paste_codepad {
my $self = shift;
my $text = join(' ', @_);
@ -510,6 +537,7 @@ sub paste_codepad {
my $ua = LWP::UserAgent->new();
$ua->agent("Mozilla/5.0");
push @{ $ua->requests_redirectable }, 'POST';
$ua->timeout(10);
my %post = ( 'lang' => 'Plain Text', 'code' => $text, 'private' => 'True', 'submit' => 'Submit' );
my $response = $ua->post("http://codepad.org", \%post);
@ -530,6 +558,7 @@ sub paste_sprunge {
my $ua = LWP::UserAgent->new();
$ua->agent("Mozilla/5.0");
$ua->requests_redirectable([ ]);
$ua->timeout(10);
my %post = ( 'sprunge' => $text, 'submit' => 'Submit' );
my $response = $ua->post("http://sprunge.us", \%post);