Work/skip dates cleaner

This commit is contained in:
Egor Guslyancev 2023-11-01 03:15:28 -03:00
parent 4e57c091ae
commit e27795c17a
GPG Key ID: D7E709AA465A55F9
1 changed files with 10 additions and 0 deletions

10
bot.py
View File

@ -965,6 +965,14 @@ def stack_update(forum: int, force_reset = False):
order.pop(0)
write_db(str(forum) + ".rookies.order", order)
def clean_old_dates(date, array: str):
a = read_db(array)
for i in range(len(a)):
if a[i] < date:
a[i] = None
a = [i for i in a if i is not None]
write_db(array, a)
def update(forum: int):
now = get_time(forum)
now_date = now.date()
@ -974,6 +982,8 @@ def update(forum: int):
is_active = get_status(forum, now_date)
hours_range = get_hours(forum)
change_phase(forum, now_date)
clean_old_dates(now_date, str(forum) + ".schedule.work_days")
clean_old_dates(now_date, str(forum) + ".schedule.skip_days")
if is_active and (last_upd_stack is None or now_date > last_upd_stack):
write_db(str(forum) + ".schedule.last_stack_update_date", now_date)
stack_update(forum)