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

[Feature] 黑名单功能 #90

Merged
merged 1 commit into from
Mar 9, 2024
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ docker-compose -f docker-compose.yml up
| --- | --- | --- |
| `command_prefix` | 机器人命令前缀 | 默认为 `/` ,可以设置为`>>`、`!` 等任意字符,可以为空,此项为空时触发命令不需要命令前缀 |
| `need_mentioned` | 群聊中的命令是否需要@机器人 | 默认为 `False` |
| `ban_person_list` | 黑名单用户列表 | 机器人不会响应黑名单用户的消息 |
| `ban_group_list` | 黑名单群列表 | 机器人不会响应黑名单群的消息 |

### ⚙️ LLM 配置

Expand Down
2 changes: 2 additions & 0 deletions config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ bot_name: Cassius
# Chat
command_prefix: /
need_mentioned: False
ban_person_list: [ ]
ban_group_list: [ ]


# LLM
Expand Down
Empty file removed ttt.css
Empty file.
Empty file removed ttt.xml
Empty file.
14 changes: 14 additions & 0 deletions wechatter/message/message_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ def handle_message(self, message_obj: Message):
处理消息
:param message_obj: 消息对象
"""
# 判断是否为黑名单
if (
config.get("ban_person_list")
and message_obj.person.name in config["ban_person_list"]
):
logger.info(f"黑名单用户:{message_obj.person.name}")
return
if (
message_obj.is_group
and config.get("ban_group_list")
and message_obj.group.name in config["ban_group_list"]
):
logger.info(f"黑名单群:{message_obj.group.name}")
return

# 公众号文章提醒
if (
Expand Down
Loading