nonebot聊天屏蔽词插件
Project description
聊天屏蔽词插件
使用例子
在使用时先确定需要在env
中配置开启哪个或者全部开启
blockwords_bot = True # 开启后机器人发送的文本消息会被进行检查
blockwords_user = False # 关闭这个配置将不会检查用户发送的消息
然后可以通过在env
中修改配置屏蔽词,可选择配置blockwords
或者配置blockwords_file
blockwords
添加屏蔽词
blockwords=["鸡", "垃圾", "废物"]
blockwords_file
添加屏蔽词文件(确保文件存在)
blockwords_file="blockwords.txt"
blockwords_file=["blockwords1.txt", "blockwords2.txt"]
接下来我们将使用console
进行演示,我会将屏蔽词都写入到一个blockwords.txt
的文件下,并且只开启blockwords_bot
是不是觉得很有趣,当然,你如果希望机器人发送的消息屏蔽词转成特定的字符,你可以使用blockwords_replace
配置项,以下是blockwords_replace
配置项使用例子。
BLOCKWORDS_REPLACE="*" # 将屏蔽词替换为*
尝试使用blockwords_user
配置
我们在使用blockwords_user
时可以去配置一段触发屏蔽词的代码
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
Close
Hashes for nonebot_plugin_blockwords-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26dafa0b0583c75fb9fbd445e7a83c0fa18022ac1920c67999c36e1470181079 |
|
MD5 | 5c40bc0dc2c60bf6d3da24472edb569a |
|
BLAKE2b-256 | 174c1611352aa291da24554243f75f826292cf362a8803bb988bac97b904b4fa |
Close
Hashes for nonebot_plugin_blockwords-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cb4ccd873e4ff6a994dd1ec23788497eb5167683e10065edf28083459d09799 |
|
MD5 | 4de56812bdaebb2674e27ed63da33b8f |
|
BLAKE2b-256 | 00e2d66779e49953776bb537ee6fb8ccd559d02e1ea90ae312b4cab12b645e0f |