伊地知ニジカ放送局だぬ゛ん゛. https://www.youtube.com/@deerjika
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.py 1.8 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import pygame
  2. from pygame.locals import *
  3. import sys
  4. import pytchat
  5. import time
  6. import random
  7. from talk import Talk
  8. import subprocess
  9. YOUTUBE_ID: str = 'aq3QwuYz-KU'
  10. class Main:
  11. @classmethod
  12. def main (cls) -> None:
  13. pygame.init ()
  14. screen: pygame.Surface = pygame.display.set_mode ((1024, 768))
  15. balloon = pygame.transform.scale (pygame.image.load ('talking.png'),
  16. (1024, 384))
  17. pygame.mixer.init (frequency = 44100)
  18. noon = pygame.mixer.Sound ('noon.wav')
  19. live_chat = pytchat.create (video_id = YOUTUBE_ID)
  20. user_font = pygame.font.SysFont ('notosanscjkjp', 32,
  21. italic = True)
  22. nizika_font = pygame.font.SysFont ('07nikumarufont', 50)
  23. while (True):
  24. screen.fill ((0, 255, 0))
  25. if live_chat.is_alive ():
  26. messages: list[str] = [c.message
  27. for c in live_chat.get ().items]
  28. if messages:
  29. message: str = random.choice (messages)
  30. answer: str = Talk.main (message)
  31. screen.blit (balloon, (0, 0))
  32. screen.blit (user_font.render ('> ' + message, True,
  33. (0, 0, 0)),
  34. (120, 70))
  35. screen.blit (nizika_font.render (
  36. answer, True, (192, 0, 0)), (100, 150))
  37. noon.play ()
  38. # subprocess.run (r'wine .\')
  39. time.sleep (10)
  40. pygame.display.update ()
  41. for event in pygame.event.get ():
  42. if event.type == QUIT:
  43. pygame.quit ()
  44. sys.exit ()
  45. if __name__ == '__main__':
  46. Main.main ()