Skip to main content
logo

✨ pErithacus ✨

LICENSE pypi python uv
ruff

简介

pErithacus 是一个基于 NoneBot2 框架的聊天插件,可以根据用户设定的关键词自动回复相关内容。该插件提供了完整的词条管理功能,让用户能够轻松创建、编辑和管理自定义回复内容。 pErithacus,名称来自灰鹦鹉(Psittacus erithacus),具有极强的语言模仿能力

功能特性

  • 📝 词条管理:添加、删除、修改、查看词条
  • 🔍 多种匹配模式:支持精准匹配、模糊匹配和正则表达式匹配
  • ⏰ 定时触发:支持使用 cron 表达式设置定时自动触发回复
  • 🎲 随机回复:可设置多个回复内容并随机选择
  • 🌐 作用域管理:支持按群组或私聊会话分别管理不同的词条
  • 🔗 别名词条:可以为词条设置别名,增加使用的灵活性

安装方法

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-pErithacus --upgrade

使用 pypi 源安装

nb plugin install nonebot-plugin-pErithacus --upgrade -i "https://pypi.org/simple"

使用清华源安装

nb plugin install nonebot-plugin-pErithacus --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-pErithacus
uv
uv add nonebot-plugin-pErithacus

安装仓库 master 分支

uv add git+https://github.com/SnowMoonSS/nonebot-plugin-pErithacus@master
pdm
pdm add nonebot-plugin-pErithacus

安装仓库 master 分支

pdm add git+https://github.com/SnowMoonSS/nonebot-plugin-pErithacus@master
poetry
poetry add nonebot-plugin-pErithacus

安装仓库 master 分支

poetry add git+https://github.com/SnowMoonSS/nonebot-plugin-pErithacus@master

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_perithacus"]
使用 nbr 安装(使用 uv 管理依赖可用)

nbr 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2

nbr plugin install nonebot-plugin-pErithacus

使用 pypi 源安装

nbr plugin install nonebot-plugin-pErithacus -i "https://pypi.org/simple"

使用清华源安装

nbr plugin install nonebot-plugin-pErithacus -i "https://pypi.tuna.tsinghua.edu.cn/simple"

🎉 使用

启动

启动收到如下提示时:

目标数据库未更新到最新迁移, 是否更新? [y/N]:

输入 y 然后回车确认,数据库将自动更新到最新迁移。

基本命令

pe <子命令> [选项...] [参数...]

发送 pe --help 查看详细的命令帮助信息。详情可查看command.py

add | 添加

添加新的词条到系统中。

语法:

pe add <关键词> <回复内容> [选项...]

参数:

  • 关键词: 要匹配的关键词。支持图片、@、纯文字,但不支持混合消息。
  • 回复内容: 当匹配成功时,BOT 会发送的内容。支持图片、@、纯文字,以及混合消息。

选项:

  • -m, --match: 匹配方式(精准/模糊),默认为精准。
  • -r, --random: 是否随机回复,默认为True。为否时回复为最后添加的内容。
  • -c, --cron: 定时触发的cron表达式,默认为空。详见CRON 表达式
  • -s, --scope: 作用域。该参数配合<关键词>进行词条查询,默认为当前会话所在作用域。指定作用域时,将会在指定作用域匹配对应的词条,并向其添加作用域。详见作用域。
  • -R, --reg: 正则匹配的正则表达式,默认为空。当存在正则表达式时,将不会进行模糊匹配。
  • -a, --alias: 为词条添加别名,默认为空。一次只能添加一个别名。

说明:

插件会先从数据库中查找已有词条。排除已删除的,根据已有的匹配方式、正则表达式在当前会话所在作用域或指定的作用域中匹配。

如果匹配到多条词条,将只会为最近修改过的词条进行操作。

del | 删除

删除指定的词条。

语法:

pe del <关键词> [选项]

参数:

  • 关键词: 要删除的词条关键词

选项:

  • -s, --scope: 作用域。要删除的词条所处的作用域。默认为当前会话所在的作用域。指定作用域时,将会根据指定作用域匹配对应的词条,然后删除该词条。详见作用域

说明:

不会真的从数据库中删除词条,只是标记为已删除。未指定作用域时,删除当前会话所在的作用域。

若删除后不存在作用域,将在数据库中标记为已删除状态。

list

列出所有词条或指定词条的详细内容。

语法:

pe list [页码] [选项...]

参数:

  • 页码 (可选): 列出指定页的词条。默认为1。

选项:

  • -s, --scope: 列出指定作用域的词条。默认为当前会话所在作用域。详见作用域
  • -a, --all: 列出所有作用域的词条。默认为False。
  • -f, --force: 列出包含已被删除的词条。默认为False。

说明: -a和-f可以配合使用。

search | 搜索

根据关键词搜索相关的词条。

语法:

pe search <关键词> [页码] [选项...]

参数:

  • 关键词: 搜索关键词
  • 页码 (可选): 列出指定页的词条。默认为1。

选项:

  • -s, --scope: 列出指定作用域的词条。默认为当前会话所在作用域。详见作用域
  • -a, --all: 列出所有作用域的词条。默认为False。

check | 查看

查看指定词条的配置信息。

语法:

pe check <词条ID> [选项]

参数:

  • 词条ID: 要查看的词条ID

选项:

  • -f, --force: 强制查看已被标记为删除的词条

detail | 详情

查看指定词条的详细内容。

语法:

pe detail <词条ID> [页码] [选项]

参数:

  • 词条ID: 要查看的词条ID。
  • 页码 (可选): 列出指定页的词条。默认为1。

选项:

  • -f, --force: 强制查看已被标记为删除的内容。
  • -a, --all: 列出包含已删除的所有内容。默认为False。

说明: -a和-f可以配合使用。

edit | 修改

修改已有词条的配置。

语法:

pe edit <关键词> [选项...]

参数:

  • 关键词: 要修改的词条关键词

选项:

  • -m, --match: 修改当前的匹配方式(精准/模糊)。默认为精准。
  • -r, --random: 是否随机回复,默认为True。为否时回复为最后添加的内容。
  • -c, --cron: 替换当前的cron表达式。详见CRON 表达式
  • -s, --scope: 作用域。该参数配合<关键词>进行词条查询,默认为当前会话所在作用域。指定作用域时,将会根据指定作用域对应的词条,并向其添加作用域。详见作用域
  • -R, --regex: 修改正则匹配的正则表达式。当存在正则表达式时,将不会进行模糊匹配。
  • -a, --alias: 为词条添加别名。一次只能添加一个别名。
  • -d, --delete: 根据指定的内容ID,删除词条内的相应内容。
  • -rep, --replace:
    • <内容ID>: 要替换的回复内容ID。
    • <内容>: 替换为的内容。

说明: 插件会先从数据库中查找已有词条。排除已删除的,根据已有的匹配方式、正则表达式在当前会话所在作用域或指定的作用域中匹配。 如果匹配到多条词条,将只会为最近修改过的词条进行操作。 要对作用域进行缩减,使用del命令

匹配方式

精准匹配

消息内容必须与关键词完全一致才会触发回复。

模糊匹配

消息内容包含关键词即可触发回复。

正则匹配

消息内容符合指定的正则表达式才会触发回复。当存在正则表达式时,将不会进行模糊匹配。

CRON 表达式

定时任务使用标准的 cron 表达式格式,以#进行分割: 分 时 日 月 周

例如:0#0#8#*#*#* 表示每天上午8点触发

可根据crontab guru编写cron表达式。添加定时消息时记得用#替换掉空格。

作用域

作用域用于控制词条的有效范围:

  • 以 g 开头表示群组作用域,如 g123456
  • 以 u 开头表示私聊作用域,如 u123456
  • 多个作用域使用,进行分割,如 g123456,u123456

示例

添加一条简单的问候语:

pe add hello 你好!

添加每日定时提醒,每天早上9点发送消息:

pe add 晨报 新的一天开始了! -c 0#9#*#*#*

添加带模糊匹配的词条:

pe add 笑话 这是一个有趣的笑话 -m 模糊

查看当前作用域的所有未删除词条:

pe list

查看词库所有未删除的词条:

pe list -a

搜索相关词条:

pe search 笑话

数据存储

数据存储在 nonebot-plugin-localstore 定义的 data 目录下。

在不同的操作系统中,数据存储路径不同:

  • macOS: ~/Library/Application Support/nonebot2
  • Unix: ~/.local/share/nonebot2 or in $XDG_DATA_HOME, if defined
  • Win XP (not roaming): C:\Documents and Settings<username>\Application Data\nonebot2
  • Win 7 (not roaming): C:\Users<username>\AppData\Local\nonebot2

可在.env文件中添加LOCALSTORE_USE_CWD = True使其保存在当前工作目录下

已知的问题

  • 没有删除别名的方法

Metadata

Release files for nonebot-plugin-pErithacus 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-pErithacus 1.2.3
File Size Uploaded Provenance Actions
nonebot_plugin_perithacus-1.2.3.tar.gz 23.5 kB With provenance Details for nonebot_plugin_perithacus-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-pErithacus 1.2.3
File Interpreter ABI Platform Actions
nonebot_plugin_perithacus-1.2.3-py3-none-any.whl Python 3 none any Details for nonebot_plugin_perithacus-1.2.3-py3-none-any.whl

Total release size: 58.2 kB

Release files / nonebot_plugin_perithacus-1.2.3.tar.gz

Download URL nonebot_plugin_perithacus-1.2.3.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e50735c81efc9dbcfcb8f08db10b11c2dd840ea1b9515577ee92753ff531b25b
BLAKE2b-256 checksum
How to use checksums
e7e47cd872452fd4bfe0279e01e02cf8e98467122db4a9a4301281c02ee679c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 4, 2026.

Transparency log

Release files / nonebot_plugin_perithacus-1.2.3-py3-none-any.whl

Download URL nonebot_plugin_perithacus-1.2.3-py3-none-any.whl
Size 34.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
018dcbb8cbc4e103f68042a775b371918cb8080f53e168c7289c47730b9e87df
BLAKE2b-256 checksum
How to use checksums
c36e583d26dd66025d857a58c05d267cf623e98d045ee47fcc1432e15b953eb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 4, 2026.

Transparency log

Security for nonebot-plugin-pErithacus 1.2.3

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nonebot_plugin_perithacus-1.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 4, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page