Browse Source

nizika_ai をいったん除外 ( #31 )

ai-migration
みてるぞ 4 weeks ago
parent
commit
7289fe5812
3 changed files with 43 additions and 9 deletions
  1. +0
    -3
      .gitmodules
  2. +0
    -1
      nizika_ai
  3. +43
    -5
      test.py

+ 0
- 3
.gitmodules View File

@@ -1,3 +0,0 @@
[submodule "nizika_ai"]
path = nizika_ai
url = https://git.miteruzo.com/miteruzo/nizika_ai

+ 0
- 1
nizika_ai

@@ -1 +0,0 @@
Subproject commit 3ca5f7c83f5f23ece55de18d626aca3f4648502b

+ 43
- 5
test.py View File

@@ -1,6 +1,7 @@
from __future__ import annotations

import math
import random
import sys
from datetime import datetime, timedelta
from enum import Enum, auto
@@ -10,16 +11,18 @@ import cv2
import ephem # type: ignore
import pygame
import pygame.gfxdraw
import pytchat
import pytchat # type: ignore
from cv2 import VideoCapture
from ephem import Moon, Observer, Sun # type: ignore
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
from pytchat.core.pytchat import PytchatCore # type: ignore
from pytchat.processors.default.processor import Chat # type: ignore

from common_module import CommonModule
from nizika_ai.models import Answer, AnsweredFlag, Query, User

pygame.init ()

@@ -29,16 +32,19 @@ SYSTEM_FONT = pygame.font.SysFont ('notosanscjkjp', 24, bold = True)
USER_FONT = pygame.font.SysFont ('notosanscjkjp', 32, italic = True)
DEERJIKA_FONT = pygame.font.SysFont ('07nikumarufont', 50)

PYTCHAT = pytchat.create (os.environ['BROADCAST_CODE'])


def main (
) -> None:
game = Game ()
Bg (game)
Deerjika (game, DeerjikaPattern.RELAXED, x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120)
Deerjika (game, DeerjikaPattern.RELAXED, x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120)
Deerjika (game, DeerjikaPattern.RELAXED, x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120)
Deerjika (game, DeerjikaPattern.RELAXED, x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120)
Deerjika (game, DeerjikaPattern.RELAXED, x = CWindow.WIDTH * 3 / 4, y = CWindow.HEIGHT - 120)
balloon = Balloon (game)
CurrentTime (game, SYSTEM_FONT)
broadcast = Broadcast ()
try:
Sound ('assets/bgm.mp3').play (loops = -1)
except Exception:
@@ -48,6 +54,11 @@ def main (
if event.type == pygame.QUIT:
pygame.quit ()
sys.exit ()
chat = broadcast.fetch_chat ()
chat.message = emoji.emojize (chat.message)
message: str = chat.message
if where chat.author.channelId
# chat.author
game.redraw ()


@@ -132,6 +143,7 @@ class Game:
def __init__ (
self,
):
self.now = datetime.now ()
self.screen = pygame.display.set_mode ((CWindow.WIDTH, CWindow.HEIGHT))
self.clock = Clock ()
self.frame = 0
@@ -323,6 +335,9 @@ class Deerjika (GameObject):
(self.width * self.scale, self.height * self.scale))
self.game.screen.blit (surface, surface.get_rect (center = (self.x, self.y)))
super ().redraw ()
self.x = random.randrange (CWindow.WIDTH)
self.y = random.randrange (CWindow.HEIGHT)
self.arg = math.radians (random.randrange (360))


class CurrentTime (GameObject):
@@ -517,7 +532,7 @@ class Jojoko (GameObject):
def redraw (
self,
) -> None:
if self.frame % 300 == 0:
if self.frame % (FPS * 3600) == 0:
self.surface = self._get_surface ()
surface = pygame.transform.rotate (self.surface, -(90 + math.degrees (self.arg)))
surface.set_colorkey ((0, 255, 0))
@@ -641,5 +656,28 @@ def get_surfaces_from_video (
return surfaces


class Broadcast:
chat: PytchatCore

def __init__ (
self,
):
self.chat = pytchat.create (os.environ['BROADCAST_CODE'])

def fetch_chat (
self,
) -> Chat | None:
if not self.chat.is_alive ():
return None
chats = self.chat.get ().items
if not chats:
return None
return random.choice (chats)


class Log:
...


if __name__ == '__main__':
main ()

Loading…
Cancel
Save