Skip to main content

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

image-20231003153146954

是不是觉得很有趣,当然,你如果希望机器人发送的消息屏蔽词转成特定的字符,你可以使用blockwords_replace配置项,以下是blockwords_replace配置项使用例子。

BLOCKWORDS_REPLACE="*"	# 将屏蔽词替换为*

image-20231003154251844

尝试使用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("不许说脏话")

image-20231003155210208

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

nonebot_plugin_blockwords-0.1.0.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page