forked from sandboxdream/AI-Vtuber
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41f9110
commit 375769d
Showing
45 changed files
with
59,477 additions
and
8,872 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,4 +175,7 @@ kuaishou.py | |
|
||
douyin/config2.json | ||
douyin/out/*.mp3 | ||
douyin/log/*.txt | ||
douyin/log/*.txt | ||
|
||
test/ | ||
game/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 导入所需的库 | ||
from bilibili_api import live, sync | ||
|
||
from utils.my_handle import My_handle | ||
|
||
my_handle = My_handle("config2.json") | ||
if my_handle is None: | ||
print("程序初始化失败!") | ||
exit(0) | ||
|
||
|
||
# 初始化 Bilibili 直播间 | ||
room = live.LiveDanmaku(my_handle.get_room_id()) | ||
|
||
|
||
@room.on('DANMU_MSG') | ||
async def on_danmaku(event): | ||
""" | ||
处理直播间弹幕事件 | ||
:param event: 弹幕事件数据 | ||
""" | ||
content = event["data"]["info"][1] # 获取弹幕内容 | ||
user_name = event["data"]["info"][2][1] # 获取发送弹幕的用户昵称 | ||
|
||
my_handle.commit_handle(user_name, content) | ||
|
||
|
||
try: | ||
# 启动 Bilibili 直播间连接 | ||
sync(room.connect()) | ||
except KeyboardInterrupt: | ||
print('程序被强行退出') | ||
finally: | ||
print('关闭连接...') | ||
exit(0) |
Oops, something went wrong.