#31 ぼちぼち
このコミットが含まれているのは:
+1
-1
@@ -1,5 +1,5 @@
|
||||
/connection.py
|
||||
/__pycache__
|
||||
__pycache__
|
||||
/nizika_talking.wav
|
||||
/youtube.py
|
||||
/log.txt
|
||||
|
||||
+1
-1
サブモジュール nizika_ai が更新されました: 662b7d69de...ed1085535e
@@ -10,21 +10,22 @@ from typing import Callable, TypedDict
|
||||
|
||||
import cv2
|
||||
import emoji
|
||||
import ephem # type: ignore
|
||||
import ephem
|
||||
import pygame
|
||||
import pygame.gfxdraw
|
||||
import pytchat # type: ignore
|
||||
import pytchat
|
||||
import requests
|
||||
from cv2 import VideoCapture
|
||||
from ephem import Moon, Observer, Sun # type: ignore
|
||||
from ephem import Moon, Observer, Sun
|
||||
from pygame import Rect, Surface
|
||||
from pygame.font import Font
|
||||
from pygame.mixer import Sound
|
||||
from pygame.time import Clock
|
||||
from pytchat.core.pytchat import PytchatCore # type: ignore
|
||||
from pytchat.processors.default.processor import Chat # type: ignore
|
||||
from pytchat.core.pytchat import PytchatCore
|
||||
from pytchat.processors.default.processor import Chat
|
||||
|
||||
from common_module import CommonModule
|
||||
from nizika_ai.config import DB
|
||||
from nizika_ai.models import Answer, AnsweredFlag, Query, User
|
||||
from nizika_ai.consts import AnswerType, Character, GPTModel, Platform, QueryType
|
||||
|
||||
@@ -58,16 +59,18 @@ def main (
|
||||
if event.type == pygame.QUIT:
|
||||
pygame.quit ()
|
||||
sys.exit ()
|
||||
answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value)
|
||||
.where ('answered', False)
|
||||
.get ())
|
||||
if not balloon.enabled:
|
||||
answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value)
|
||||
.where ('answered', False)
|
||||
.get ())
|
||||
if answer_flags:
|
||||
answer_id: int = random.choice (answer_flags).answer_id
|
||||
answer = Answer.find (answer_id)
|
||||
answer_flag = random.choice (answer_flags)
|
||||
answer = Answer.find (answer_flag.answer_id)
|
||||
if answer.answer_type == AnswerType.YOUTUBE_REPLY.value:
|
||||
query = Query.find (answer.query_id)
|
||||
balloon.talk (query.content, answer.content)
|
||||
answer_flag.answered = True
|
||||
answer_flag.save ()
|
||||
add_query (broadcast)
|
||||
game.redraw ()
|
||||
|
||||
@@ -705,6 +708,7 @@ def add_query (
|
||||
chat = broadcast.fetch_chat ()
|
||||
if chat is None:
|
||||
return
|
||||
DB.begin_transaction ()
|
||||
chat.message = emoji.emojize (chat.message)
|
||||
message: str = chat.message
|
||||
user = (User.where ('platform', Platform.YOUTUBE.value)
|
||||
@@ -726,6 +730,8 @@ def add_query (
|
||||
query.sent_at = datetime.now ()
|
||||
query.answerd = False
|
||||
query.save ()
|
||||
DB.commit ()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main ()
|
||||
|
||||
新しい課題から参照
ユーザをブロックする