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