Skip to content

Commit

Permalink
feat: 黑名单功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassius0924 committed Mar 9, 2024
1 parent 7bb30d0 commit 6e8c5e9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
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

0 comments on commit 6e8c5e9

Please sign in to comment.