#
# 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
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!
close ($fh);
exit;
}
+unless ($ongstate < STATE->{'end'}) {
+ print "END\n\n";
+ close ($fh);
+ exit;
+}
$next_ong = int($state{'nextong'});
print 'ongtime: '.$next_ong."\n";
$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";
}
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);