]> bicyclesonthemoon.info Git - ott/bsta/commitdiff
no state update (time) in case ONG failed. stay at EE:EE:EE v1.2.14
authorb <rowerynaksiezycu@gmail.com>
Thu, 19 Mar 2026 21:04:56 +0000 (21:04 +0000)
committerb <rowerynaksiezycu@gmail.com>
Thu, 19 Mar 2026 21:04:56 +0000 (21:04 +0000)
ong.1.pl
settings.txt

index df5eab07d05965a158c421c77b0e7ede8a435921..086b0d703697e28f4259b8b48223006ad421c571 100644 (file)
--- a/ong.1.pl
+++ b/ong.1.pl
@@ -4,7 +4,7 @@
 #
 # The ONG bot
 #
-# Copyright (C) 2016, 2017, 2023, 2024  Balthasar Szczepański
+# Copyright (C) 2016, 2017, 2023, 2024, 2026  Balthasar Szczepański
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as
@@ -65,6 +65,7 @@ my $static_timer;
 my $timer;
 my $last;
 my $r = 0;
+my $update_state = 0;
 
 $ongtime = int($time / 3600) * 3600; # check time as if it was last full hour!
 
@@ -90,6 +91,11 @@ unless ($ongstate > STATE->{'inactive'}) {
        close ($fh);
        exit;
 }
+unless ($ongstate < STATE->{'end'}) {
+       print "END\n\n";
+       close ($fh);
+       exit;
+}
 $next_ong = int($state{'nextong'});
 print 'ongtime: '.$next_ong."\n";
 
@@ -116,9 +122,6 @@ if ($static_timer > $timer) {
        $timer = $static_timer;
 }
 $next_ong = $ongtime + ($timer*3600);
-$state{'nextong'} = $next_ong;
-print 'next ongtime: '.$next_ong.' (+'.$timer.")\n";
-$state{'ongtime'}=$timer;
 
 if ($ongstate == STATE->{'ready'}) {
        print 'next frame: '.$frame."\n";
@@ -203,11 +206,22 @@ if ($ongstate == STATE->{'ready'}) {
        }
        if ($r) {
                %state = %new_state;
+               $update_state = 1;
+               print 'next ongtime: '.$next_ong.' (+'.$timer.")\n";
                print "ONG\n\n";
        }
        else {
                print "NO ONG\n\n";
        }
 }
-write_state($fh, \%state);
+else {
+       $state{'nextong'} = $next_ong;
+       $state{'ongtime'} = $timer;
+       $update_state = 1;
+}
+if ($update_state) {
+       print 'not ready'."\n";
+       print 'next ongtime: '.$next_ong.' (+'.$timer.")\n";
+       write_state($fh, \%state);
+}
 close ($fh);
index a61dc98fbf0fc33a5d4da2f84e2037caa5c49816..954f894b6f1233b1582fe20b99cde52603321ee1 100644 (file)
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-_version: 1.2.13
+_version: 1.2.14
 
 _SHEBANG: #!$0