]> bicyclesonthemoon.info Git - ott/post/commitdiff
wget-related extended not tested
authorb <rowerynaksiezycu@gmail.com>
Fri, 7 Jul 2023 23:53:31 +0000 (23:53 +0000)
committerb <rowerynaksiezycu@gmail.com>
Fri, 7 Jul 2023 23:53:31 +0000 (23:53 +0000)
sendpost.1.pl
settings-debug.txt
settings-release.txt
settings.txt

index c2a64512b7cb252177498c88d57655913f518890..4ae5fd9b30f38a270e4d28b863bb5436efe16154 100644 (file)
@@ -36,6 +36,8 @@ use botm_common (
 ###PERL_DEFAULT_SUBJECT:  use constant DEFAULT_SUBJECT  => 'Re: 1190: "Time"';
 ###PERL_DEFAULT_USERNAME: use constant DEFAULT_USERNAME => 'username';
 
+###PERL_WGET_USERAGENT: use constant WGET_USERAGENT => "post tool (http://bicyclesonthemoon.info/git-projects/?p=ott/post)";
+
 ###PERL_WGET: use constant WGET => '/usr/bin/wget';
 
 ###PERL_TMP_PATH: use constant TMP_PATH   => '/botm/tmp/post';
@@ -74,7 +76,7 @@ binmode STDOUT, ':encoding(console_out)';
 binmode STDERR, ':encoding(console_out)';
 decode_argv();
 
-my %options = {};
+my %options = ();
 
 Getopt::Long::Configure('bundling');
 GetOptions (
@@ -102,6 +104,7 @@ GetOptions (
        'mirror-url|R=s' => \$options{   'mirror-url'},
        
        'help|h'         => \$options{   'help'}
+       # TODO: useragent
 );
 
 if ($options{'help'} ne '') {
@@ -276,12 +279,45 @@ sub post_to_mirror {
        my %wget_options = (
                'with_header', 1,
                'cookie_path', $cookie_path,
-               'postdata_path', $postdata_path
-       );
-       my %post_data = (
-               'uvwxyz', 'eół',
-               'lel', 'lol'
        );
+       my %post_data = ();
+       my %query_data = ();
+       
+       if ($cmd_options{'edit'} ne '') {
+               $query_data{'e'} = $cmd_options{'edit'};
+       }
+       if (keys %query_data) {
+               my $query = join_url(\%query_data);
+               my %query_url = ('query' => $query);
+               $post_url = merge_url($post_url, \%query_url);
+       }
+       
+       wget($post_url, $tmp_path, \%wget_options,);
+       
+       $wget_options{'referer'} = $post_url;
+       $wget_options{'postdata_path'} = postdata_path;
+       
+       $post_data{'subject'} = $post->{'subject'};
+       $post_data{'username'} = $post->{'username'};
+       $post_data{'password'} = $post->{'password'};
+       $post_data{'password2'} = '';
+       $post_data{'message'} = $post->{'content'};
+       unless ($post->{'bbcode'}) {
+               $post_data{'disable_bbcode'} = 'on';
+       }
+       unless ($post->{'smilies'}) {
+               $post_data{'disable_smilies'} = 'on';
+       }
+       unless ($post->{'urls'}) {
+               $post_data{'disable_magic_url'} = 'on';
+       }
+       if ($post->{'signature'}) {
+               $post_data{'attach_sig'} = 'on';
+       }
+       if ($post->{'notify'}) {
+               $post_data{'notify'} = 'on';
+       }
+       $post_data{'post'} = 'Submit';
        
        wget($post_url, $tmp_path, \%wget_options, \%post_data);
        
@@ -294,7 +330,10 @@ sub wget {
        
        my @arg = (
                WGET,
-               '-q'
+               '-q',
+               '-t', WGET_RETRIES,
+               '--connect-timeout=', WGET_TIMEOUT,
+               '-U', WGET_USERAGENT
        );
        
        if ($options->{'with_header'}) {
@@ -311,6 +350,10 @@ sub wget {
                push(@arg, '--no-cookies');
        }
        
+       if ($options->{'referer'} ne '') {
+               push(@arg, '--referer=', $options->{'referer'});
+       }
+       
        if ($options->{'postdata_path'} ne '') {
                if (defined $postdata) {
                        write_postdata_file(
index ce4b63a4119f8068c963e01fbb4ad52f40b645fd..c10ec4c62169cab46325ef6caaf19b16d586feca 100644 (file)
@@ -19,6 +19,9 @@ default_subject: Re: 1190: "Time"
 default_username: _
 default_password: _
 
+wget_useragent: post tool (http://bicyclesonthemoon.info/git-projects/?p=ott/post)
+wget_retries: 3
+wget_timeout: 60
 
 cp: /usr/bin/cp
 chmod: /usr/bin/chmod
index 328922624f586093ca6e689b6a6664da689307b5..97a6a39accb9c0dbe1b92d8cbe1001a8365fba20 100644 (file)
@@ -19,6 +19,10 @@ default_subject: Re: 1190: "Time"
 default_username: _
 default_password: _
 
+wget_useragent: post tool (http://bicyclesonthemoon.info/git-projects/?p=ott/post)
+wget_retries: 3
+wget_timeout: 60
+
 
 cp: /usr/bin/cp
 chmod: /usr/bin/chmod
index ebb76d2a1538c0ed2b8a166e210fd63f82b5fe36..a82e4cdea7460ebdb6776a76379266dc61275d73 100644 (file)
@@ -46,6 +46,10 @@ PERL_ENCODING_FILE     = @_PERL_CONSTANT_STR( ENCODING_FILE    , $encoding_file)
 PERL_MIRROR_URL        = @_PERL_CONSTANT_STR( MIRROR_URL       , $mirror_url)
 PERL_TMP_PATH          = @_PERL_CONSTANT_STR( TMP_PATH         , $tmp_path)
 
+PERL_WGET_RETRIES      = @_PERL_CONSTANT_STR( WGET_RETRIES     , $wget_retries)
+PERL_WGET_TIMEOUT      = @_PERL_CONSTANT_STR( WGET_TIMEOUT     , $wget_timeout)
+PERL_WGET_USERAGENT    = @_PERL_CONSTANT_STR( WGET_USERAGENT   , $wget_useragent)
+
 PERL_WGET              = @_PERL_CONSTANT_STR( WGET             , $wget)
 
 PERL_LIB = @_PERL_USE_2(lib, @_PERL_STR($lib_path))