Skip to content

Commit

Permalink
抖音关注事件可以触发关注感谢话术
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Sep 2, 2023
1 parent bfd5d9a commit 08cb3b2
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 221 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ cmd运行`npm i docsify-cli -g`
- [x] 支持关闭聊天(LLM等)
- [x] langchain-chatglm的接入
- [ ] Edge-TTS在合成音频时会出现合成成功但是系统找不到文件的bug
- [ ] 抖音关注事件可以触发关注感谢话术
- [x] 抖音关注事件可以触发关注感谢话术

## 📝更新日志

Expand Down Expand Up @@ -1574,6 +1574,7 @@ cmd运行`npm i docsify-cli -g`
- 补充、删减部分违禁词
- 补充遗漏的zhipuai库
- 入场和礼物感谢部分删除用户名中存在的特殊符号
- 抖音关注事件可以触发关注感谢话术

</details>

Expand Down
241 changes: 135 additions & 106 deletions UI_main.py

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@
"gift_forget_reserve_num": 1,
"entrance_forget_duration": 5.0,
"entrance_forget_reserve_num": 2,
"follow_forget_duration": 3.0,
"follow_forget_reserve_num": 1,
"talk_forget_duration": 0.1,
"talk_forget_reserve_num": 1,
"schedule_forget_duration": 0.1,
"schedule_forget_reserve_num": 1
},
"thanks": {
"entrance_enable": true,
"entrance_copy": "欢迎{username}",
"gift_enable": true,
"entrance_copy": "欢迎 {username}",
"gift_copy": "感谢 {username} 送的 {gift_name}",
"gift_copy": "感谢{username}送的{gift_name}",
"follow_enable": true,
"follow_copy": "感谢{username}的关注",
"lowest_price": 1.0
},
"live2d": {
Expand Down
8 changes: 6 additions & 2 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@
"gift_forget_reserve_num": 1,
"entrance_forget_duration": 5.0,
"entrance_forget_reserve_num": 2,
"follow_forget_duration": 3.0,
"follow_forget_reserve_num": 1,
"talk_forget_duration": 0.1,
"talk_forget_reserve_num": 1,
"schedule_forget_duration": 0.1,
"schedule_forget_reserve_num": 1
},
"thanks": {
"entrance_enable": true,
"entrance_copy": "欢迎{username}",
"gift_enable": true,
"entrance_copy": "欢迎 {username}",
"gift_copy": "感谢 {username} 送的 {gift_name}",
"gift_copy": "感谢{username}送的{gift_name}",
"follow_enable": true,
"follow_copy": "感谢{username}的关注",
"lowest_price": 1.0
},
"live2d": {
Expand Down
9 changes: 9 additions & 0 deletions dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,16 @@ def on_message(ws, message):
my_handle.process_data(data, "entrance")

elif type == 4:
user_name = data_json["User"]["Nickname"]

logging.info(f'[➕直播间关注消息] 感谢 {data_json["User"]["Nickname"]} 的关注')

data = {
"username": user_name
}

my_handle.process_data(data, "follow")

pass

elif type == 5:
Expand Down Expand Up @@ -242,6 +250,7 @@ def on_message(ws, message):
def on_error(ws, error):
logging.error("Error:", error)


def on_close(ws):
logging.debug("WebSocket connection closed")

Expand Down
23 changes: 20 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def init_config(self):
self.ui.label_local_qa_audio_file_path.setToolTip("本地问答音频文件存储路径")
self.ui.label_local_qa_audio_similarity.setToolTip("最低音频匹配相似度,就是说用户发送的内容和本地音频库中音频文件名的最低相似度。\n低了就会被当做一般弹幕处理")

# 过滤
self.ui.label_filter_before_must_str.setToolTip("弹幕过滤,必须携带的触发前缀字符串(任一)\n例如:配置#,那么就需要发送:#你好")
self.ui.label_filter_after_must_str.setToolTip("弹幕过滤,必须携带的触发后缀字符串(任一)\n例如:配置。那么就需要发送:你好。")
self.ui.label_filter_badwords_path.setToolTip("本地违禁词数据路径(你如果不需要,可以清空文件内容)")
Expand All @@ -438,16 +439,21 @@ def init_config(self):
self.ui.label_filter_gift_forget_reserve_num.setToolTip("保留最新收到的数据的数量")
self.ui.label_filter_entrance_forget_duration.setToolTip("指的是每隔这个间隔时间(秒),就会丢弃这个间隔时间中接收到的数据,\n保留数据在以下配置中可以自定义")
self.ui.label_filter_entrance_forget_reserve_num.setToolTip("保留最新收到的数据的数量")
self.ui.label_filter_follow_forget_duration.setToolTip("指的是每隔这个间隔时间(秒),就会丢弃这个间隔时间中接收到的数据,\n保留数据在以下配置中可以自定义")
self.ui.label_filter_follow_forget_reserve_num.setToolTip("保留最新收到的数据的数量")
self.ui.label_filter_talk_forget_duration.setToolTip("指的是每隔这个间隔时间(秒),就会丢弃这个间隔时间中接收到的数据,\n保留数据在以下配置中可以自定义")
self.ui.label_filter_talk_forget_reserve_num.setToolTip("保留最新收到的数据的数量")
self.ui.label_filter_schedule_forget_duration.setToolTip("指的是每隔这个间隔时间(秒),就会丢弃这个间隔时间中接收到的数据,\n保留数据在以下配置中可以自定义")
self.ui.label_filter_schedule_forget_reserve_num.setToolTip("保留最新收到的数据的数量")

# 答谢
self.ui.label_thanks_entrance_enable.setToolTip("是否启用欢迎用户进入直播间功能")
self.ui.label_thanks_gift_enable.setToolTip("是否启用感谢用户赠送礼物功能")
self.ui.label_thanks_entrance_copy.setToolTip("用户进入直播间的相关文案,请勿动 {username},此字符串用于替换用户名")
self.ui.label_thanks_gift_enable.setToolTip("是否启用感谢用户赠送礼物功能")
self.ui.label_thanks_gift_copy.setToolTip("用户赠送礼物的相关文案,请勿动 {username} 和 {gift_name},此字符串用于替换用户名和礼物名")
self.ui.label_thanks_lowest_price.setToolTip("设置最低答谢礼物的价格(元),低于这个设置的礼物不会触发答谢")
self.ui.label_thanks_follow_enable.setToolTip("是否启用感谢用户关注的功能")
self.ui.label_thanks_follow_copy.setToolTip("用户关注时的相关文案,请勿动 {username},此字符串用于替换用户名")

self.ui.label_live2d_enable.setToolTip("启动web服务,用于加载本地Live2D模型")
self.ui.label_live2d_port.setToolTip("web服务运行的端口号,默认:12345,范围:0-65535,没事不要乱改就好")
Expand Down Expand Up @@ -764,6 +770,7 @@ def init_config(self):
self.ui.lineEdit_local_qa_audio_file_path.setText(self.local_qa_config['audio']['file_path'])
self.ui.lineEdit_local_qa_audio_similarity.setText(str(self.local_qa_config['audio']['similarity']))

# 过滤
tmp_str = ""
for tmp in self.filter_config['before_must_str']:
tmp_str = tmp_str + tmp + "\n"
Expand All @@ -782,6 +789,8 @@ def init_config(self):
self.ui.lineEdit_filter_gift_forget_reserve_num.setText(str(self.filter_config['gift_forget_reserve_num']))
self.ui.lineEdit_filter_entrance_forget_duration.setText(str(self.filter_config['entrance_forget_duration']))
self.ui.lineEdit_filter_entrance_forget_reserve_num.setText(str(self.filter_config['entrance_forget_reserve_num']))
self.ui.lineEdit_filter_follow_forget_duration.setText(str(self.filter_config['follow_forget_duration']))
self.ui.lineEdit_filter_follow_forget_reserve_num.setText(str(self.filter_config['follow_forget_reserve_num']))
self.ui.lineEdit_filter_talk_forget_duration.setText(str(self.filter_config['talk_forget_duration']))
self.ui.lineEdit_filter_talk_forget_reserve_num.setText(str(self.filter_config['talk_forget_reserve_num']))
self.ui.lineEdit_filter_schedule_forget_duration.setText(str(self.filter_config['schedule_forget_duration']))
Expand All @@ -791,11 +800,14 @@ def init_config(self):
# 答谢
if self.thanks_config['entrance_enable']:
self.ui.checkBox_thanks_entrance_enable.setChecked(True)
self.ui.lineEdit_thanks_entrance_copy.setText(self.thanks_config['entrance_copy'])
if self.thanks_config['gift_enable']:
self.ui.checkBox_thanks_gift_enable.setChecked(True)
self.ui.lineEdit_thanks_entrance_copy.setText(self.thanks_config['entrance_copy'])
self.ui.lineEdit_thanks_gift_copy.setText(self.thanks_config['gift_copy'])
self.ui.lineEdit_thanks_lowest_price.setText(str(self.thanks_config['lowest_price']))
if self.thanks_config['follow_enable']:
self.ui.checkBox_thanks_follow_enable.setChecked(True)
self.ui.lineEdit_thanks_follow_copy.setText(self.thanks_config['follow_copy'])

if self.live2d_config['enable']:
self.ui.checkBox_live2d_enable.setChecked(True)
Expand Down Expand Up @@ -2039,6 +2051,7 @@ def common_textEdit_handle(content):
config_data["local_qa"]["audio"]["file_path"] = self.ui.lineEdit_local_qa_audio_file_path.text()
config_data["local_qa"]["audio"]["similarity"] = round(float(self.ui.lineEdit_local_qa_audio_similarity.text()), 2)

# 过滤
config_data["filter"]["before_must_str"] = common_textEdit_handle(self.ui.textEdit_filter_before_must_str.toPlainText())
config_data["filter"]["after_must_str"] = common_textEdit_handle(self.ui.textEdit_filter_after_must_str.toPlainText())
config_data["filter"]["badwords_path"] = self.ui.lineEdit_filter_badwords_path.text()
Expand All @@ -2051,17 +2064,21 @@ def common_textEdit_handle(content):
config_data["filter"]["gift_forget_reserve_num"] = int(self.ui.lineEdit_filter_gift_forget_reserve_num.text())
config_data["filter"]["entrance_forget_duration"] = round(float(self.ui.lineEdit_filter_entrance_forget_duration.text()), 2)
config_data["filter"]["entrance_forget_reserve_num"] = int(self.ui.lineEdit_filter_entrance_forget_reserve_num.text())
config_data["filter"]["follow_forget_duration"] = round(float(self.ui.lineEdit_filter_follow_forget_duration.text()), 2)
config_data["filter"]["follow_forget_reserve_num"] = int(self.ui.lineEdit_filter_follow_forget_reserve_num.text())
config_data["filter"]["talk_forget_duration"] = round(float(self.ui.lineEdit_filter_talk_forget_duration.text()), 2)
config_data["filter"]["talk_forget_reserve_num"] = int(self.ui.lineEdit_filter_talk_forget_reserve_num.text())
config_data["filter"]["schedule_forget_duration"] = round(float(self.ui.lineEdit_filter_schedule_forget_duration.text()), 2)
config_data["filter"]["schedule_forget_reserve_num"] = int(self.ui.lineEdit_filter_schedule_forget_reserve_num.text())

# 答谢
config_data["thanks"]["entrance_enable"] = self.ui.checkBox_thanks_entrance_enable.isChecked()
config_data["thanks"]["gift_enable"] = self.ui.checkBox_thanks_gift_enable.isChecked()
config_data["thanks"]["entrance_copy"] = self.ui.lineEdit_thanks_entrance_copy.text()
config_data["thanks"]["gift_enable"] = self.ui.checkBox_thanks_gift_enable.isChecked()
config_data["thanks"]["gift_copy"] = self.ui.lineEdit_thanks_gift_copy.text()
config_data["thanks"]["lowest_price"] = round(float(self.ui.lineEdit_thanks_lowest_price.text()), 2)
config_data["thanks"]["follow_enable"] = self.ui.checkBox_thanks_follow_enable.isChecked()
config_data["thanks"]["follow_copy"] = self.ui.lineEdit_thanks_follow_copy.text()

config_data["live2d"]["enable"] = self.ui.checkBox_live2d_enable.isChecked()
live2d_port = self.ui.lineEdit_live2d_port.text()
Expand Down
Loading

0 comments on commit 08cb3b2

Please sign in to comment.