Nonebot2 plugin for making memes
Project description
本插件为 nonebot-plugin-memes 调用 api 版本
可以将本插件与 meme-generator 分开部署
安装
- 使用 nb-cli
nb plugin install nonebot_plugin_memes_api
- 使用 pip
pip install nonebot_plugin_memes_api
并按照 NoneBot 加载插件 加载插件
配置驱动器
插件需要“客户端型驱动器”(如 httpx)来下载图片等,驱动器安装和配置参考 NoneBot 选择驱动器
同时需要在 .env.* 配置文件中启用对应的驱动器,例如:
DRIVER=~fastapi+~httpx+~websockets
配置项
以下配置项可在
.env.*文件中设置,具体参考 NoneBot 配置方式
meme_generator_base_url
- 类型:
str - 默认:
http://127.0.0.1:2233 - 说明:
meme-generatorweb server 地址
memes_command_prefixes
- 类型:
List[str] | None - 默认:
None - 说明:命令前缀(仅作用于制作表情的命令);如果不设置默认使用 NoneBot 命令前缀
memes_disabled_list
- 类型:
List[str] - 默认:
[] - 说明:禁用的表情包列表,需填写表情的
key,可在 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" - 说明:表情排序方式,可用值:
"key"(按表情key排序)、"keywords"(按表情首个关键词排序)、"date_created"(按表情添加时间排序)、"date_modified"(按表情修改时间排序)
- 类型:
sort_reverse- 类型:
bool - 默认:
False - 说明:是否倒序排序
- 类型:
text_template- 类型:
str - 默认:
"{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": "{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-plugin-memes 基本一致
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_memes_api-0.5.1.tar.gz.
File metadata
- Download URL: nonebot_plugin_memes_api-0.5.1.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.11.0 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8385cf5cb8d47e6e185c93c62f09f2dddeaf18fe9a0c9f3a5e0761a0788db8b
|
|
| MD5 |
324111fd49044655b0206fa4b5b32b2f
|
|
| BLAKE2b-256 |
c71f81037b8d5c76e420b0d7b2e6f364963878544d3972ad6ae8700a5ad3a36f
|
File details
Details for the file nonebot_plugin_memes_api-0.5.1-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_memes_api-0.5.1-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.11.0 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8de1122bbedd150f261ac9a6d5204231d7ca5c9cdca6469733c3159cbca0338
|
|
| MD5 |
7c43cf87a087ad34e75063fd4fe44305
|
|
| BLAKE2b-256 |
1bd72504527105bb066993da39a31ed25f3e3aad3bb225ccb7d9e075023016b8
|