|
|
|
@@ -79,13 +79,16 @@ def main ( |
|
|
|
|
|
|
|
if now_m - last_flags_poll >= 10: |
|
|
|
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) |
|
|
|
.get ()) |
|
|
|
log (f"pending: { len (answer_flags) }") |
|
|
|
if answer_flags: |
|
|
|
answer_flag = random.choice (answer_flags) |
|
|
|
log (f"flag_id: { answer_flag.id }, answer_id: { answer_flag.answer_id }") |
|
|
|
answer = Answer.find (answer_flag.answer_id) |
|
|
|
match QueryType (answer.query_rel.query_type): |
|
|
|
case QueryType.YOUTUBE_COMMENT: |
|
|
|
@@ -102,12 +105,14 @@ def main ( |
|
|
|
DB.commit () |
|
|
|
except Exception as ex: |
|
|
|
DB.rollback () |
|
|
|
log ('EXCEPTION in poll loop') |
|
|
|
print (ex) |
|
|
|
|
|
|
|
try: |
|
|
|
if broadcast is not None: |
|
|
|
add_query (broadcast) |
|
|
|
except Exception as ex: |
|
|
|
log ('EXCEPTION in adding a query') |
|
|
|
print (ex) |
|
|
|
game.redraw () |
|
|
|
|
|
|
|
@@ -998,5 +1003,12 @@ def add_query ( |
|
|
|
DB.commit () |
|
|
|
|
|
|
|
|
|
|
|
def log ( |
|
|
|
msg: str, |
|
|
|
) -> None: |
|
|
|
print (f"[{ datetime.now ().isoformat (sep = ' ', timespec = 'seconds') }] { msg }", |
|
|
|
flush = True) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
main () |