Browse Source

#40

feature/040
みてるぞ 11 hours ago
parent
commit
1c61d90662
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      main.py

+ 5
- 1
main.py View File

@@ -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 ()


Loading…
Cancel
Save