Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加入输出敏感词 #416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions channel/wechat/wechat_mp_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def handle(self, msg, count=1):
def _do_send(self, query, context):
key = query + '|' + context['from_user_id']
reply_text = super().build_reply_content(query, context)
with open('sensitive_words_output.txt', 'r', encoding='utf-8') as f:
sensitive_words = [line.strip() for line in f.readlines()]
for word in sensitive_words:
if word != '' and word in reply_text:
reply_text = "这个问题不大好回答,咱聊点别的好了。"
logger.info('[WX_Public] reply content: {}'.format(reply_text))
cache[key]['status'] = "success"
cache[key]['data'] = reply_text
Expand Down
1 change: 1 addition & 0 deletions sensitive_words_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@