Browse Source

#31 ぼちぼち

ai-migration
みてるぞ 3 weeks ago
parent
commit
af862a7981
5 changed files with 20 additions and 12 deletions
  1. +1
    -1
      .gitignore
  2. +0
    -0
      __init__.py
  3. +2
    -0
      mypy.ini
  4. +1
    -1
      nizika_ai
  5. +16
    -10
      test.py

+ 1
- 1
.gitignore View File

@@ -1,5 +1,5 @@
/connection.py
/__pycache__
__pycache__
/nizika_talking.wav
/youtube.py
/log.txt

+ 0
- 0
__init__.py View File


+ 2
- 0
mypy.ini View File

@@ -0,0 +1,2 @@
[mypy]
disable_error_code = import-untyped

+ 1
- 1
nizika_ai

@@ -1 +1 @@
Subproject commit 662b7d69de66bb8c09f8297817449179166c0f3d
Subproject commit ed1085535e2c05b04f31b0d0ff933152b47bf5b5

+ 16
- 10
test.py View File

@@ -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 ()

Loading…
Cancel
Save