本插件是 表情包生成器 meme-generator 的 Nonebot2 对接插件,方便通过聊天机器人制作表情包
另有 nonebot-plugin-memes-api(表情包制作 调用 api 版本),可以将 NoneBot 插件与 meme-generator 分开部署
nonebot-plugin-memes-api 与 nonebot-plugin-memes 功能上基本一致
安装
- 使用 nb-cli
nb plugin install nonebot_plugin_memes
- 使用 pip
pip install nonebot_plugin_memes
并按照 NoneBot 加载插件 加载插件
配置驱动器
插件需要“客户端型驱动器”(如 httpx)来下载图片等,驱动器安装和配置参考 NoneBot 选择驱动器
同时需要在 .env.* 配置文件中启用对应的驱动器,例如:
DRIVER=~fastapi+~httpx+~websockets
配置项
以下配置项可在
.env.*文件中设置,具体参考 NoneBot 配置方式
memes_command_prefixes
- 类型:
List[str] | None - 默认:
None - 说明:命令前缀(仅作用于制作表情的命令);如果不设置默认使用 NoneBot 命令前缀
memes_disabled_list
- 类型:
List[str] - 默认:
[] - 说明:禁用的表情包列表,需填写表情的
key,可在 meme-generator 表情列表 中查看。若只是临时关闭,可以用下文中的“表情包开关”
memes_check_resources_on_startup
- 类型:
bool - 默认:
True - 说明:是否在启动时检查
meme-generator资源
memes_params_mismatch_policy
- 类型:
MemeParamsMismatchPolicy - 说明:图片/文字数量不符时的处理方式,其中具体设置项如下:
too_much_text- 类型:
str - 默认:
"ignore" - 可选项:
"ignore"(忽略本次命令)、"prompt"(发送提示),"drop"(去掉多余的文字)
- 类型:
too_few_text- 类型:
str - 默认:
"ignore" - 可选项:
"ignore"(忽略本次命令)、"prompt"(发送提示),"get"(交互式获取所需的文字)
- 类型:
too_much_image- 类型:
str - 默认:
"ignore" - 可选项:
"ignore"(忽略本次命令)、"prompt"(发送提示),"drop"(去掉多余的图片)
- 类型:
too_few_image- 类型:
str - 默认:
"ignore" - 可选项:
"ignore"(忽略本次命令)、"prompt"(发送提示),"get"(交互式获取所需的图片)
- 类型:
memes_params_mismatch_policy在.env文件中的设置示例如下:
memes_params_mismatch_policy='
{
"too_much_text": "drop",
"too_few_text": "get",
"too_much_image": "drop",
"too_few_image": "get"
}
'
memes_use_sender_when_no_image
- 类型:
bool - 默认:
False - 说明:在表情需要至少 1 张图且没有输入图片时,是否使用发送者的头像
memes_use_default_when_no_text
- 类型:
bool - 默认:
False - 说明:在表情需要至少 1 段文字且没有输入文字时,是否使用默认文字
memes_random_meme_show_info
- 类型:
bool - 默认:
True - 说明:使用“随机表情”时是否同时发出表情关键词
memes_list_image_config
- 类型:
MemeListImageConfig - 说明:表情列表图相关设置,其中具体设置项如下:
sort_by- 类型:
str - 默认:
"keywords_pinyin" - 说明:表情排序方式,可用值:
"key"(按表情key排序)、"keywords"(按表情关键词排序)、keywords_pinyin(按表情关键词拼音排序)、"date_created"(按表情添加时间排序)、"date_modified"(按表情修改时间排序)
- 类型:
sort_reverse- 类型:
bool - 默认:
False - 说明:是否倒序排序
- 类型:
text_template- 类型:
str - 默认:
"{index}. {keywords}" - 说明:表情显示文字模板,可用变量:
"{index}"(序号)、"{key}"(表情名)、"{keywords}"(关键词)、"{shortcuts}"(快捷指令)、"{tags}"(标签)
- 类型:
add_category_icon- 类型:
bool - 默认:
True - 说明:是否添加图标以表示类型,即“图片表情包”和“文字表情包”
- 类型:
label_new_timedelta- 类型:
timedelta - 默认:
timedelta(days=30) - 说明:表情添加时间在该时间间隔以内时,添加
new图标
- 类型:
label_hot_threshold- 类型:
int - 默认:
21 - 说明:单位:次;表情在
label_hot_days内的调用次数超过该阈值时,添加hot图标
- 类型:
label_hot_days- 类型:
int - 默认:
7 - 说明:单位:天;表情调用次数统计周期
- 类型:
memes_list_image_config在.env文件中的设置示例如下:
memes_list_image_config='
{
"sort_by": "keywords",
"sort_reverse": false,
"text_template": "{index}. {keywords}",
"add_category_icon": true,
"label_new_timedelta": "P30D",
"label_hot_threshold": 21,
"label_hot_days": 7
}
'
memes_multiple_image_config
- 类型:
MultipleImageConfig - 说明:发送多张图片时的相关设置,其中具体设置项如下:
direct_send_threshold- 类型:
int - 默认:
10 - 说明:发送图片数量大于该数目时,不再直接发送,而是以文件或合并转发消息的形式发送
- 类型:
send_zip_file- 类型:
bool - 默认:
True - 说明:发送图片数量大于
direct_send_threshold时,是否打包为zip以文件形式发送
- 类型:
send_forward_msg- 类型:
bool - 默认:
False - 说明:发送图片数量大于
direct_send_threshold时,是否发送合并转发消息
- 类型:
memes_multiple_image_config在.env文件中的设置示例如下:
memes_multiple_image_config='
{
"direct_send_threshold": 10,
"send_zip_file": true,
"send_forward_msg": true
}
'
使用
以下命令需要加 NoneBot 命令前缀 (默认为/),可自行添加空字符
表情列表
- 发送 “表情包制作” 查看表情列表
表情详情
- 发送 “表情详情 + 关键词” 查看表情详细信息和表情预览
表情搜索
- 发送 “表情搜索 + 关键词” 查找相关的表情
表情包开关
“超级用户” 和 “管理员” 可以启用或禁用某些表情
- 发送 “启用表情/禁用表情 + 关键词”,如:
禁用表情 摸
“超级用户” 可以设置某个表情包的管控模式(黑名单/白名单)
-
发送 “全局启用表情 + 关键词” 可将表情设为黑名单模式;
-
发送 “全局禁用表情 + 关键词” 可将表情设为白名单模式;
表情使用
- 发送 “关键词 + 图片/文字” 制作表情
可使用 “自己”、“@某人” 获取指定用户的头像作为图片
可使用 “@ + 用户 id” 指定任意用户获取头像,如 摸 @114514
可将回复中的消息作为文字和图片的输入
指定用户时将使用用户昵称作为“图片名”
可使用“# + 名字”指定“图片名”,如 小天使 #name 自己
示例:
随机表情
- 发送 “随机表情 + 图片/文字” 可随机制作表情
随机范围为 图片/文字 数量符合要求的表情
表情调用统计
- 发送 “[我的][全局]<时间段>表情调用统计 [表情名]” 获取表情调用次数统计图
“我的”、“全局”、<时间段>、“表情名” 均为可选项
<时间段> 可以为:日、本日、周、本周、月、本月、年、本年
如:我的今日表情调用统计 petpet
简单图片操作
插件附带了简单图片操作功能,发送 “图片操作” 查看帮助
可用的指令有:
- 水平翻转/左翻/右翻
- 竖直翻转/上翻/下翻
- 旋转 + 角度
- 缩放 + 尺寸或百分比,如:
缩放 100x100;缩放 200x;缩放 150% - 裁剪 + 尺寸或比例,如:
裁剪 100x100;裁剪 2:1 - 灰度图/黑白
- 反相/反色
- 横向拼接 + 至少两张图片
- 纵向拼接 + 至少两张图片
- gif分解
- gif合成 + 至少两张图片
- gif倒放/倒放
- gif变速 + 倍率或fps,如:
gif变速 0.5x;gif变速 10fps
相关插件
- nonebot-plugin-alconna 强大的 Nonebot2 命令匹配拓展,支持富文本/多媒体解析,跨平台消息收发
- nonebot-plugin-uninfo Nonebot2 多平台的会话信息(用户、群组、频道)获取插件
- nonebot-plugin-orm SQLAlchemy support for NoneBot2
Metadata
Release files for nonebot_plugin_memes 0.8.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_memes-0.8.1.tar.gz | 25.7 kB | Without provenance | Details for nonebot_plugin_memes-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_memes-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_memes-0.8.1-py3-none-any.whl |
Total release size: 56.3 kB
Release files / nonebot_plugin_memes-0.8.1.tar.gz
| Download URL | nonebot_plugin_memes-0.8.1.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
202b06134bc3a7734939401c94bb891a3f6986afd51df99d5e7743fbd216ebc2
|
|
BLAKE2b-256 checksum How to use checksums |
2093a0f7005bf1de32741dfcf4e857f9ca4e5c7c6d40c4dd6e6b41bcd1a6c23a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.0 Linux/6.8.0-1021-azure
|
Release files / nonebot_plugin_memes-0.8.1-py3-none-any.whl
| Download URL | nonebot_plugin_memes-0.8.1-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae0ce656c4c85d632e1489fe128e3305801c04e6e04eebb9c595137c9b33e99a
|
|
BLAKE2b-256 checksum How to use checksums |
d7ac2eea067e019bc8471c21c96899581d03af9cb183cae7d8a4b94c7abd5371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.0 Linux/6.8.0-1021-azure
|
Security for nonebot_plugin_memes 0.8.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.