From abb2f05798ea6ed4d230ba1e18e9d8a051b116c2 Mon Sep 17 00:00:00 2001 From: Migatu Date: Wed, 10 Apr 2024 16:27:45 +0200 Subject: [PATCH] Communication work progress FX aa Maybe wrong Another step forward. STOP! --- bot.py | 27 ++++++++++++++++++++++++--- communication_subroutine.py | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 739a1e3..c789683 100644 --- a/bot.py +++ b/bot.py @@ -682,11 +682,32 @@ async def check_music(): @tasks.loop(seconds=3) # trunk-ignore(pylint/R0915) async def check_data_q(): - channel = client.get_channel(1062047367337095268) try: data = IN_COMM_Q.get(block=False) - if data.finished: - await channel.send(f"O. A tak będzie wyglądało coś ciekawego w przyszłości: {data}") + if data.stop: + searcher = data.author + ctx = data.ctx + query = data.content + entries = data.replies + message = '*Z podłogi wysuwa się winda na książki*' + message += f' Dzielny poszukiwaczu {searcher} w odpowiedzi na twoje zapytanie {query}' + message += 'nasza biblioteka służy Ci odpowiedzią. Przy dźwięku fanfar winda się otwiera a w środku ' + if len(entries)<1: + message += "niestety nie ma nic" + elif len(entries)>1 and len(entries)<5: + message += " znajduje się coś:\n" + for item in entries: + message+=str(item["DOI"]) + else: + message+= " znajduje się cholernie dużo:\n" + for item in entries: + message+=str(item["DOI"]) + if len(message) > 1500: + await ctx.send(message) + message = "" + + await ctx.send(message) + #await ctx.send(f"O. A tak będzie wyglądało coś ciekawego w przyszłości: {data}") except Empty: pass diff --git a/communication_subroutine.py b/communication_subroutine.py index cfeddca..76b4954 100644 --- a/communication_subroutine.py +++ b/communication_subroutine.py @@ -25,6 +25,7 @@ def answer_external_command(): break if q_data.uuid in record: q_data.stop = True + q_data.entries = record IN_COMM_Q.put(q_data) return jsonify("SUCCESS")