This article is the 25th day article of VTuber Tech # 1 Advent Calendar 2019. I usually work as a Vtuber under the name Soki Tamaki.
I made an app that allows chat to flow from right to left. We also implemented commands to change the font color, play voice, and make it rain.
Functional test Actual use (latest delivery)
↓ Please use it as you like. Source code The one that was converted to exe with pyinstaller
Enter the delivery ID (the one in the URL) next to the window ID that appears when you start it, and press the ok button. If there is nothing, the comment will flow on the green screen.
setting.json --"chat_id" Enter the delivery ID here. (You can enter it on the software at startup) --You can change the window resolution with [Vertical resolution, Horizontal resolution] of "win_size". --You can specify the background color with [R, G, B] of "back_color".
chat_setting.json --"plain_font_path" allows you to specify the font file to use by default.
--You can set voice commands with "sound_commands". You can also add new ones.
--You can set commands to change the speed of characters with "speed_commands". If you specify a minus for "speed", the flow will be reversed.
--You can set the command to change the text color with "color_commands". Specify with [R, G, B]. "outline_color" is a border color setting with only one dot.
--You can set commands that randomly drop characters with "rain_commands". One of the characters in "drops" will randomly drop from the top for the number of seconds of "time". You can set the initial velocity and acceleration.
~~ At first, I was forced to get a chat with Selenium ~~
I was able to afford it by using pychat (thanks). It worked just by passing the ID in the delivery URL.
Sample code
from pytchat import LiveChat
import time
def main()
chat = LiveChat("Put id here", callback = func)
while chat.is_alive():
time.sleep(3)
#Write your favorite process
#If you pass a function to the callback argument, you will receive chats on a regular basis.
def func(data):
for c in data.items:
print(f"{c.datetime} [{c.author.name}]-{c.message} {c.amountString}")
data.tick()
However, there was a bug that python did not quit when it was incorporated into the app.
When I called chat.terminate ()
, it ended normally.
There is a Japanese translation reference, so I did it while looking at it.
--pygame can put both strings and images on Surface
objects
--I stumbled upon specifying the installed font, so I loaded .ttf
directly.
--When emoji comes in, it will be killed, so Destroy emoji
--Since character edging is not implemented as standard, I used ** here **.
--Command function
--Simply prepare a process for comments that include character strings such as / red
--By rewriting json, you can increase the number of commands that play text colors and sounds as you like.
--Play audio
--Of course you can do it with pygame
--Using the mixer.Sound
class for sound effects
--ID input ――Pygame doesn't have familiar input forms and buttons --Display a window to enter ID with tkinter at startup
--Chat is fun ――It's fun to increase the number of commands as much as you want --The delivery screen is lively and fun
Recommended Posts