聊天屏蔽词插件
聊天屏蔽词插件是所有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("不许说脏话")
Metadata
Release files for nonebot-plugin-blockwords 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_plugin_blockwords-0.2.1.tar.gz | 7.2 kB | Without provenance | Details for nonebot_plugin_blockwords-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_blockwords-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_blockwords-0.2.1-py3-none-any.whl |
Total release size: 17.4 kB
Release files / nonebot_plugin_blockwords-0.2.1.tar.gz
| Download URL | nonebot_plugin_blockwords-0.2.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
136bb6f414720a41b64efbb52394b92beb6710910c918371f51854f927247540
|
|
BLAKE2b-256 checksum How to use checksums |
a4cb0f5f13cedbfe3db375dc7b49fbfbd7f7062103901c96b4c71790fbc6c555
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.13 Windows/10
|
Release files / nonebot_plugin_blockwords-0.2.1-py3-none-any.whl
| Download URL | nonebot_plugin_blockwords-0.2.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44c3c07be3c0cfd529ae669a1496b76421582cf7c117632420a47d2944a659be
|
|
BLAKE2b-256 checksum How to use checksums |
daea1e345706d0197e6c800500589debab3f20e76911291e13ac7b20e5a1fa9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.13 Windows/10
|
Security for nonebot-plugin-blockwords 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.