新增启动状态

main
Zhangzhichao@123 4 weeks ago
parent 55f04eb6f1
commit 94654ac0c7

@ -162,9 +162,10 @@ class LiveChatConfig:
cursor.close()
return int(livetalking_sessionid)
def update_chat_enable_status(self):
def update_chat_enable_status(self, status):
status_dict = {'未启动': 0, '启动中': 1, '已启动': 2, '启动失败': 3}
cursor = self.conn.cursor()
cursor.execute("update live_config set value = 1 where key = 'chat_enable_status'")
cursor.execute("update live_config set value = ? where key = 'chat_enable_status'", (status_dict[status],))
self.conn.commit()
cursor.close()

@ -96,6 +96,7 @@ class DouyinLiveWebFetcher:
self.__ttwid = None
self.__room_id = None
self.live_id = LiveChatConfig().live_id
logger.info(f'self.live_id: {self.live_id}')
self.live_url = "https://live.douyin.com/"
self.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " \
"Chrome/120.0.0.0 Safari/537.36"
@ -103,7 +104,12 @@ class DouyinLiveWebFetcher:
self.ws_open_event = ws_open_event
def start(self):
self._connectWebSocket()
try:
self._connectWebSocket()
except Exception as e:
live_chat_config.update_chat_enable_status('启动失败')
logger.error(traceback.format_exc())
raise e
def stop(self):
self.ws.close()
@ -382,7 +388,7 @@ class DouyinLiveWebReply:
"""
优先从用户交互队列中取提示词如果没有用户交互的数据则输出系统提示词
"""
live_chat_config.update_chat_enable_status()
live_chat_config.update_chat_enable_status('已启动')
logger.info(f'livetalking address -> {self.live_chat_config.livetalking_address}')
logger.info(f'ollama_address -> {self.live_chat_config.ollama_address}')
while True:

@ -1,5 +1,5 @@
from liveMan import DouyinLiveWebFetcher, DouyinLiveWebReply
from helper import PromptQueue
from helper import PromptQueue, LiveChatConfig
from multiprocessing import Process, Event, freeze_support
from loguru import logger
@ -19,6 +19,8 @@ def reply_user_chat_content(queue):
if __name__ == '__main__':
freeze_support()
LiveChatConfig().update_chat_enable_status('启动中')
queue = PromptQueue(10)
ws_open_event = Event()

Loading…
Cancel
Save