From c9f8062699cb6cdb0c88905448b7712c9b8aeb60 Mon Sep 17 00:00:00 2001 From: b Date: Thu, 19 Mar 2026 21:04:56 +0000 Subject: [PATCH] no state update (time) in case ONG failed. stay at EE:EE:EE --- ong.1.pl | 24 +++++++++++++++++++----- settings.txt | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ong.1.pl b/ong.1.pl index df5eab0..086b0d7 100644 --- 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); diff --git a/settings.txt b/settings.txt index a61dc98..954f894 100644 --- a/settings.txt +++ b/settings.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -_version: 1.2.13 +_version: 1.2.14 _SHEBANG: #!$0 -- 2.30.2