|
|
@@ -11,6 +11,7 @@ from playsound import playsound |
|
|
|
from common_module import CommonModule |
|
|
|
from youtube import * |
|
|
|
from datetime import datetime |
|
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
class Main: |
|
|
@@ -30,17 +31,40 @@ class Main: |
|
|
|
italic = True) |
|
|
|
nizika_font = pygame.font.SysFont ('07nikumarufont', 50) |
|
|
|
|
|
|
|
messages: list[str] = [] |
|
|
|
|
|
|
|
while (True): |
|
|
|
screen.fill ((0, 255, 0)) |
|
|
|
|
|
|
|
for i in range (4): |
|
|
|
screen.blit ( |
|
|
|
system_font.render ( |
|
|
|
f'live_chat.is_alive () == {live_chat.is_alive ()}', |
|
|
|
True, (0, 0, 0)), |
|
|
|
(i % 2, i // 2 * 2)) |
|
|
|
screen.blit ( |
|
|
|
system_font.render (str (datetime.now ()), True, (0, 0, 0)), |
|
|
|
(i % 2, 32 + i // 2 * 2)) |
|
|
|
|
|
|
|
if live_chat.is_alive (): |
|
|
|
screen.blit ( |
|
|
|
system_font.render ( |
|
|
|
f'messages == {messages}', |
|
|
|
True, (0, 0, 0)), |
|
|
|
(i % 2, 64 + i // 2 * 2)) |
|
|
|
|
|
|
|
if live_chat.is_alive (): |
|
|
|
messages: list[str] = [c.message |
|
|
|
for c in live_chat.get ().items] |
|
|
|
chat_items: list = live_chat.get ().items |
|
|
|
|
|
|
|
if messages: |
|
|
|
message: str = random.choice (messages) |
|
|
|
if chat_items: |
|
|
|
chat_item = random.choice (chat_items) |
|
|
|
chat_item.author = chat_item.author.__dict__ |
|
|
|
message: str = chat_item.message |
|
|
|
answer: str = Talk.main (message) |
|
|
|
|
|
|
|
with open ('log.txt', 'a') as f: |
|
|
|
f.write (f'{datetime.now ()}\t{json.dumps (chat_item.__dict__)}\t{answer}\n') |
|
|
|
|
|
|
|
screen.blit (balloon, (0, 0)) |
|
|
|
screen.blit ( |
|
|
|
user_font.render ( |
|
|
@@ -72,23 +96,6 @@ class Main: |
|
|
|
else: |
|
|
|
live_chat = pytchat.create (video_id = YOUTUBE_ID) |
|
|
|
|
|
|
|
for i in range (4): |
|
|
|
screen.blit ( |
|
|
|
system_font.render ( |
|
|
|
f'live_chat.is_alive () == {live_chat.is_alive ()}', |
|
|
|
True, (0, 0, 0)), |
|
|
|
(i % 2, i // 2 * 2)) |
|
|
|
screen.blit ( |
|
|
|
system_font.render (str (datetime.now ()), True, (0, 0, 0)), |
|
|
|
(i % 2, 32 + i // 2 * 2)) |
|
|
|
|
|
|
|
if live_chat.is_alive (): |
|
|
|
screen.blit ( |
|
|
|
system_font.render ( |
|
|
|
f'messages == {messages}', |
|
|
|
True, (0, 0, 0)), |
|
|
|
(i % 2, 64 + i // 2 * 2)) |
|
|
|
|
|
|
|
pygame.display.update () |
|
|
|
|
|
|
|
for event in pygame.event.get (): |
|
|
|