Skip to content

Commit

Permalink
Merge pull request #670 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
动态文案 生成的文案内容 默认进行 违禁词、链接、纯标点的过滤
  • Loading branch information
Ikaros-521 committed Feb 29, 2024
2 parents c127c91 + af98b1e commit 2fc3b29
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ async def run_trends_copywriting():
# 空数据判断
if data_json["content"] != None and data_json["content"] != "":
# 发给直接复读进行处理
my_handle.reread_handle(data_json)
my_handle.reread_handle(data_json, filter=True)

await asyncio.sleep(config.get("trends_copywriting", "play_interval"))
except Exception as e:
Expand Down
19 changes: 18 additions & 1 deletion utils/my_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,12 @@ def prohibitions_handle(self, content):


# 直接复读
def reread_handle(self, data):
def reread_handle(self, data, filter=False):
"""复读处理
Args:
data (dict): 包含用户名,弹幕内容
filter (bool): 是否开启复读内容的过滤
Returns:
_type_: 寂寞
Expand All @@ -1021,6 +1022,22 @@ def reread_handle(self, data):
content = data["content"]

logging.info(f"复读内容:{content}")

if filter:
# 违禁处理
content = self.prohibitions_handle(content)
if content is None:
return

# 弹幕格式检查和特殊字符替换
content = self.comment_check_and_replace(content)
if content is None:
return

# 判断字符串是否全为标点符号,是的话就过滤
if My_handle.common.is_punctuation_string(content):
logging.debug(f"用户:{username}],发送纯符号的弹幕,已过滤")
return

# 音频合成时需要用到的重要数据
message = {
Expand Down

0 comments on commit 2fc3b29

Please sign in to comment.