diff --git a/main.py b/main.py index 8d1cfc0..65dc95f 100644 --- a/main.py +++ b/main.py @@ -63,6 +63,7 @@ def main ( waiting_balloon = (False, '', '') last_flags_poll: float = 0 + traced_af_ids: list[int] = [] while True: now_m = time.monotonic () @@ -77,13 +78,14 @@ def main ( deerjika.talk (waiting_balloon[1], waiting_balloon[2]) waiting_balloon = (False, '', '') - if now_m - last_flags_poll >= 10: + if now_m - last_flags_poll >= 1: last_flags_poll = now_m log (f"balloon: { balloon.enabled }, snack: { snack_time.enabled }") try: DB.begin_transaction () answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value) .where ('answered', False) + .where_not_in ('id', traced_af_ids) .get ()) log (f"pending: { len (answer_flags) }") if answer_flags: @@ -102,6 +104,8 @@ def main ( waiting_balloon = (True, query.content, answer.content) answer_flag.answered = True answer_flag.save () + case _: + traced_af_ids.append (answer_flag.id) DB.commit () except Exception as ex: DB.rollback ()