nonebot聊天屏蔽词插件
Project description
聊天屏蔽词插件
聊天屏蔽词插件是所有adapter的通用的插件,可以对用户发送的词进行检测然后进行自定义操作,例如屏蔽词中加入一些辱骂词汇,检测到辱骂词汇时进行撤回或者禁言等操作,也可以对机器人发送的进行检测,如果存在屏蔽词进行拦截发送或者替换屏蔽词。
如何添加屏蔽词
-
配置
env中的blockwords配置项例如blockwords=["鸡", "垃圾", "废物"]
-
通过导入文件的方式可以配置
env中的blockwords_fileblockwords_file="blockwords.txt"
-
多文件导入方式
blockwords_file=["blockwords1.txt", "blockwords2.txt"]
机器人发送的消息进行屏蔽词检测
在env中配置blockwords_bot开启bot发送消息检测
blockwords_bot = True # 开启后机器人发送的消息会被进行检测
上述例子中,因为检测到机器人发送的消息存在屏蔽词,插件会拦截机器人发送的消息,如果不希望进行拦截,可以查看如何将机器人发送的屏蔽词进行替换
将机器人发送的屏蔽词进行替换
在env中配置blockwords_replace配置项,以下是blockwords_replace配置项使用例子。
BLOCKWORDS_REPLACE="*" # 将屏蔽词替换为*
接收用户消息屏蔽词检测
在env中配置blockwords_user开启接收用户所发送的消息进行检测
blockwords_user = True # 开启后机器人发送的消息会被进行检测
在检测到屏蔽词时会触发到blockwords_matcher,可以导入blockwords_matcher对触发屏蔽词后进行自定义操作
from nonebot.internal.matcher import Matcher
from nonebot_plugin_blockwords import blockwords_matcher
@blockwords_matcher.handle()
async def _(matcher: Matcher):
await matcher.finish("不许说脏话")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_blockwords-0.2.1.tar.gz.
File metadata
- Download URL: nonebot_plugin_blockwords-0.2.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
136bb6f414720a41b64efbb52394b92beb6710910c918371f51854f927247540
|
|
| MD5 |
933ea200f5f2a393de0971d629624160
|
|
| BLAKE2b-256 |
a4cb0f5f13cedbfe3db375dc7b49fbfbd7f7062103901c96b4c71790fbc6c555
|
File details
Details for the file nonebot_plugin_blockwords-0.2.1-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_blockwords-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44c3c07be3c0cfd529ae669a1496b76421582cf7c117632420a47d2944a659be
|
|
| MD5 |
a71a8fbdd518dee455fd6b40e4baa2bb
|
|
| BLAKE2b-256 |
daea1e345706d0197e6c800500589debab3f20e76911291e13ac7b20e5a1fa9e
|