Initial commit

trunk
qorg11 2021-10-07 14:07:30 +02:00
commit 968a5afd42
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
2 changed files with 41 additions and 0 deletions

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# weechat scripts
There are some weechat scripts i've written for fun, or because i was
lazy to open another terminal to run a command and they save time so
they can be useful. They are all written in Perl, so to install them,
just run `/perl load <script>` and it should work.

33
upload.pl Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/perl
# upload.pl
#
# weechat pluging for uploading files to a lainsafe instance
# license: WTFPL
use LWP::UserAgent;
our $returned_link;
weechat::register("upload.pl","qorg11","0.1","WTFPL","Uploads a file to a lainsafe instance","","");
my $hook = weechat::hook_command("upload","Uploads a file to lainsafe instance","file path","Does that","","upload_file_cb","");
sub upload_file_cb($$$) {
my $instance = "https://ls.qorg11.net";
my ($data, $buffer, $file_path) = @_;
my @chars = split("",$file_path);
if($chars[0] eq "~") {
my $home = $ENV{HOME};
$file_path =~ s/~/$home/;
}
my $ua = LWP::UserAgent->new;
$ua->agent("weechat :D");
my $req = $ua->post($instance,
Content_Type=>'form-data',
Content => ["file"=>[$file_path],]
);
$returned_link = $req->{_content};
weechat::command($buffer,$returned_link);
return weechat::WEECHAT_RC_OK;
}