diff --git a/main.py b/main.py index bc962761..f76dc653 100644 --- a/main.py +++ b/main.py @@ -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: diff --git a/utils/my_handle.py b/utils/my_handle.py index c9de0256..ee1c50d0 100644 --- a/utils/my_handle.py +++ b/utils/my_handle.py @@ -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_: 寂寞 @@ -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 = {