From 8a0abdb7fa513d48edf3ad633879e2b324b819e7 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Tue, 5 Dec 2023 00:30:06 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8B=E3=82=B8=E3=82=AB=E8=BF=94=E7=AD=94?= =?UTF-8?q?=E3=81=AE=E6=94=B9=E8=A1=8C=E3=81=A8=EF=BC=8C=E6=94=B9=E8=A1=8C?= =?UTF-8?q?=E3=82=92=E3=83=AD=E3=82=B0=E3=81=AB=E8=A8=98=E9=8C=B2=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=84=E3=81=85=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 5642648..2f42ee4 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ class Main: italic = True) nizika_font = pygame.font.SysFont ('07nikumarufont', 50) - messages: list[str] = [] + chat_items: list = [] while (True): screen.fill ((0, 255, 0)) @@ -49,7 +49,7 @@ class Main: if live_chat.is_alive (): screen.blit ( system_font.render ( - f'messages == {messages}', + f'chat_items == {chat_items}', True, (0, 0, 0)), (i % 2, 64 + i // 2 * 2)) @@ -60,7 +60,7 @@ class Main: chat_item = random.choice (chat_items) chat_item.author = chat_item.author.__dict__ message: str = chat_item.message - answer: str = Talk.main (message, chat_item.author['name']) + answer: str = Talk.main (message, chat_item.author['name']).replace ('\n', ' ') with open ('log.txt', 'a') as f: f.write (f'{datetime.now ()}\t{json.dumps (chat_item.__dict__)}\t{answer}\n') @@ -73,17 +73,35 @@ class Main: <= 21) else (CommonModule.mid_by_full ( message, 0, 19.5) - + '...')), True, (0, 0, 0)), + + '...')), + True, + (0, 0, 0)), (120, 70)) screen.blit ( - nizika_font.render (answer, True, (192, 0, 0)), + nizika_font.render ( + (answer + if CommonModule.len_by_full (answer) <= 26 + else CommonModule.mid_by_full (answer, 0, 26)), + True, + (192, 0, 0)), (100, 150)) + if CommonModule.len_by_full (answer) > 26: + screen.blit ( + nizika_font.render ( + (CommonModule.mid_by_full (answer, 26, 26) + if CommonModule.len_by_full (answer) <= 52 + else (CommonModule.mid_by_full ( + answer, 26, 24.5) + + '...')), + True, + (192, 0, 0)), + (100, 200)) pygame.display.update () noon.play () - time.sleep (2) + time.sleep (1.5) wav: bytearray | None = Aques.main (answer) if wav is not None: