]> bicyclesonthemoon.info Git - botm/oldlogs/commitdiff
fix ONG; fix update; total reset
authorb <rowerynaksiezycu@gmail.com>
Mon, 29 Jan 2024 22:26:58 +0000 (22:26 +0000)
committerb <rowerynaksiezycu@gmail.com>
Mon, 29 Jan 2024 22:26:58 +0000 (22:26 +0000)
ong.1.pl
reset.1.pl
update.1.pl

index c5a24ebf3462d276ef78ad30f88426db15323a92..6c3ecf33c2c975868ac96dd1e72011d125fd7156 100644 (file)
--- a/ong.1.pl
+++ b/ong.1.pl
@@ -135,6 +135,7 @@ if ($ongstate == STATE->{'ready'}) {
        );
        # %goto_list = read_data_file(DATA_LIST_PATH());
        
+       %new_state = %state;
        $new_state{'last'}   = $frame;
        $new_state{'state'}  = 1;
        $new_state{'ip1'}    = '';
index c43e3683a4d49b94c89c67c6f5bfe499e75d033e..a7ee374f33ac81e4d4eabe88778fcde40f384968 100644 (file)
@@ -32,7 +32,8 @@ use botm_common (
 );
 use bsta_lib (
        'STATE', 'INTF_STATE', 'CHAT_STATE',
-       'write_index'
+       'write_index',
+       'merge_settings'
 );
 
 binmode STDIN,  ':encoding(UTF-8)';
@@ -42,13 +43,18 @@ decode_argv();
 
 ###PERL_PATH_SEPARATOR:     PATH_SEPARATOR     = /
 
+###PERL_DATA_PATH:          DATA_PATH          = /botm/data/bsta/
+###PERL_DATA_ATTACH_PATH:   DATA_ATTACH_PATH   = /botm/data/bsta/a
 ###PERL_DATA_CHAT_PATH:     DATA_CHAT_PATH     = /botm/data/bsta/chat
+###PERL_DATA_DEFAULT_PATH:  DATA_DEFAULT_PATH  = /botm/data/bsta/default
 ###PERL_DATA_LIST_PATH:     DATA_LIST_PATH     = /botm/data/bsta/list
 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/state
 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
 ###PERL_DATA_STORY_PATH:    DATA_STORY_PATH    = /botm/data/bsta/story
 ###PERL_DATA_WORDS_PATH:    DATA_WORDS_PATH    = /botm/data/bsta/words/
 
+###PERL_WWW_PATH:           WWW_PATH           = /botm/www/
+
 ###PERL_RESET_PASSWORD:     RESET_PASSWORD     = ''
 
 my %story;
@@ -56,6 +62,9 @@ my %state;
 my %chat;
 my %settings;
 my %goto_list;
+my %default;
+my $last_frame;
+my @remove_list;
 
 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
@@ -71,6 +80,47 @@ unless (
        exit 1;
 }
 
+$last_frame = int($settings{'last'});
+%default = read_data_file(DATA_DEFAULT_PATH());
+
+for (my $frame=0; $frame<=$last_frame; $frame+=1) {
+       my %frame_data =read_data_file(
+               join_path(PATH_SEPARATOR(), DATA_PATH(), $frame)
+       );
+       %frame_data = merge_settings(\%default, \%frame_data);
+       unless ($frame == 0) {
+               push @remove_list, (
+                       ($frame_data{'page'} ne '') ?
+                               $frame_data{'page'} :
+                               sprintf(
+                                       $settings{'frame'},
+                                       $frame, 'htm'
+                               )
+               );
+       }
+       push @remove_list, (
+               ($frame_data{'frame'} ne '') ?
+                       $frame_data{'frame'} :
+                       sprintf(
+                               $settings{'frame'},
+                               $frame, $frame_data{'ext'}
+                       )
+       );
+}
+push @remove_list, 'goto.htm';
+for (my $i=0; ;$i+=1) {
+       my %file_data;
+       
+       %file_data = read_data_file(DATA_ATTACH_PATH().$i);
+       if ($file_data{'frame'} eq '') {
+               last;
+       }
+       if ($file_data{'content'} ne '') {
+               next;
+       }
+       push @remove_list, $file_data{'filename'};
+}
+
 %state = (
        'state' => STATE->{'inactive'},
        'last'  => 0,
@@ -115,6 +165,12 @@ if (opendir_encoded(my $dir, DATA_WORDS_PATH())) {
                        next;
                }
                my $full_path = join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $file_name);
+               # print "RM $full_path\n";
                unlink_encoded ($full_path);
        }
 }
+foreach my $file_name (@remove_list) {
+       my $full_path = join_path(PATH_SEPARATOR(), WWW_PATH(), $file_name);
+       # print "RM $full_path\n";
+       unlink_encoded ($full_path);
+}
index 1cc780342f24fcf482d8e6b8dda0ca640fe85f3f..a5f0c5efbd4e3f231efcc024d5390cc3a9aa4e00 100644 (file)
@@ -24,7 +24,7 @@ use utf8;
 use Encode::Locale ('decode_argv');
 use Encode ('encode', 'decode');
 
-use lib '/botm/lib/test-bsta';
+###PERL_LIB: use lib /botm/lib/bsta
 use botm_common (
        'read_data_file',
        'join_path'
@@ -99,6 +99,23 @@ foreach my $id (@ARGV) {
        }
 }
 
+# duplicated - before AND after normal pages!
+if ($update_goto) {
+       print 'static GOTO';
+       my $r = write_static_goto(
+               \%state,
+               \%settings,
+               '' # \%goto_list
+       );
+       if ($r) {
+               print " OK\n";
+       }
+       else {
+               print " FAIL\n";
+               $fail += 1;
+       }
+}
+
 foreach my $id (@list) {
        print "ONG $id\n";
        my $r = ong(
@@ -118,6 +135,8 @@ foreach my $id (@list) {
        }
        make_static_pages($id);
 }
+
+# duplicated - before AND after normal pages!
 if ($update_goto) {
        print 'static GOTO';
        my $r = write_static_goto(