bins/ix: move to "script" and switch to using okturing

This commit is contained in:
Aaron Bieber 2024-05-23 13:12:34 -06:00
parent a5b3a31c69
commit 6f21f362c3
No known key found for this signature in database
3 changed files with 46 additions and 35 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
result
.DS_Store
tags
*.bak

View File

@ -1,36 +1,4 @@
{ perl }: ''
#!${perl}/bin/perl
use strict;
use warnings;
use HTTP::Tiny;
if ($^O eq "openbsd") {
require OpenBSD::Pledge;
require OpenBSD::Unveil;
OpenBSD::Unveil::unveil("/", "") or die;
OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
}
my $http = HTTP::Tiny->new();
sub slurp {
my ($fh) = @_;
local $/;
<$fh>;
}
sub ix {
my ($input) = @_;
my $url = "http://sprunge.us";
my $form = [ sprunge => $input ];
my $resp = $http->post_form($url, $form)
or die "could not POST: $!";
$resp->{content};
}
my $input = slurp('STDIN');
my $url = ix($input);
print $url;
''
#!${perl}/bin/perl
${builtins.readFile ./ix/ix.pl}
''

42
bins/ix/ix.pl Normal file
View File

@ -0,0 +1,42 @@
use strict;
use warnings;
use HTTP::Tiny;
if ( $^O eq "openbsd" ) {
require OpenBSD::Pledge;
require OpenBSD::Unveil;
OpenBSD::Unveil::unveil( "/", "" ) or die;
OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
}
my $http = HTTP::Tiny->new();
sub slurp {
my ($fh) = @_;
local $/;
<$fh>;
}
sub ix {
my ($input) = @_;
my $url = "http://okturing.com";
my $form = [
a_body => $input,
submit => "submit",
fake => "fake",
a_func => "add_post"
];
my $resp = $http->post_form( $url, $form )
or die "could not POST: $!";
$resp->{content};
}
my $input = slurp('STDIN');
my $out = ix($input);
foreach my $line ($out) {
if ( $line =~ m/href="(.+okturing\.com\/src.+\/body)\"/ ) {
print $1, "\n";
last;
}
}