Metadata-Version: 2.1
Name: nonebot_plugin_memes_api
Version: 0.4.8
Summary: Nonebot2 plugin for making memes
Home-page: https://github.com/noneplugin/nonebot-plugin-memes-api
License: MIT
Author: meetwq
Author-email: meetwq@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: httpx (>=0.20.0,<1.0.0)
Requires-Dist: matplotlib (>=3.7.0,<4.0.0)
Requires-Dist: nonebot-plugin-alconna (>=0.46.3,<1.0.0)
Requires-Dist: nonebot-plugin-localstore (>=0.6.0,<1.0.0)
Requires-Dist: nonebot-plugin-orm (>=0.7.0,<1.0.0)
Requires-Dist: nonebot-plugin-session (>=0.3.0,<0.4.0)
Requires-Dist: nonebot-plugin-session-orm (>=0.2.0,<0.3.0)
Requires-Dist: nonebot-plugin-userinfo (>=0.2.1,<0.3.0)
Requires-Dist: nonebot2 (>=2.3.0,<3.0.0)
Requires-Dist: pypinyin (>=0.44.0,<1.0.0)
Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
Requires-Dist: pyyaml (>=6.0,<7.0)
Requires-Dist: rapidfuzz (>=3.9.0,<4.0.0)
Project-URL: Repository, https://github.com/noneplugin/nonebot-plugin-memes-api
Description-Content-Type: text/markdown

<div align="center">

  <a href="https://nonebot.dev/">
    <img src="https://nonebot.dev/logo.png" width="200" height="200" alt="nonebot">
  </a>

# nonebot-plugin-memes-api

_✨ [Nonebot2](https://github.com/nonebot/nonebot2) 表情包制作插件 调用 api 版本 ✨_

<p align="center">
  <img src="https://img.shields.io/github/license/noneplugin/nonebot-plugin-memes-api" alt="license">
  <img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="Python">
  <img src="https://img.shields.io/badge/nonebot-2.3.0+-red.svg" alt="NoneBot">
  <a href="https://pypi.org/project/nonebot-plugin-memes-api">
    <img src="https://badgen.net/pypi/v/nonebot-plugin-memes-api" alt="pypi">
  </a>
  <a href="https://jq.qq.com/?_wv=1027&k=wDVNrMdr">
    <img src="https://img.shields.io/badge/QQ%E7%BE%A4-682145034-orange" alt="qq group">
  </a>
</p>

</div>

> 本插件为 [nonebot-plugin-memes](https://github.com/noneplugin/nonebot-plugin-memes) 调用 api 版本
>
> 可以将本插件与 [meme-generator](https://github.com/MeetWq/meme-generator) 分开部署

### 安装

- 使用 nb-cli

```
nb plugin install nonebot_plugin_memes_api
```

- 使用 pip

```
pip install nonebot_plugin_memes_api
```

并按照 [NoneBot 加载插件](https://nonebot.dev/docs/tutorial/create-plugin#加载插件) 加载插件

#### 配置驱动器​

插件需要“客户端型驱动器”（如 httpx）来下载图片等，驱动器安装和配置参考 [NoneBot 选择驱动器](https://nonebot.dev/docs/advanced/driver)

同时需要在 `.env.*` 配置文件中启用对应的驱动器，例如：

```
DRIVER=~fastapi+~httpx+~websockets
```

#### meme-generator 部署

按照 [meme-generator 安装](https://github.com/MeetWq/meme-generator#安装) 中的说明安装，并下载图片、安装字体等

之后通过 `meme run` 启动 web server

### 配置项

> 以下配置项可在 `.env.*` 文件中设置，具体参考 [NoneBot 配置方式](https://nonebot.dev/docs/appendices/config)

#### `meme_generator_base_url`

- 类型：`str`
- 默认：`http://127.0.0.1:2233`
- 说明：`meme-generator` web server 地址

#### `memes_command_prefixes`

- 类型：`List[str] | None`
- 默认：`None`
- 说明：命令前缀（仅作用于制作表情的命令）；如果不设置默认使用 [NoneBot 命令前缀](https://nonebot.dev/docs/appendices/config#command-start-和-command-separator)

#### `memes_disabled_list`

- 类型：`List[str]`
- 默认：`[]`
- 说明：禁用的表情包列表，需填写表情的`key`，可在 [meme-generator 表情列表](https://github.com/MeetWq/meme-generator/blob/main/docs/memes.md) 中查看。若只是临时关闭，可以用下文中的“表情包开关”

#### `memes_prompt_params_error`

- 类型：`bool`
- 默认：`False`
- 说明：是否在图片/文字数量不符时提示（谨慎使用，容易误触发）

#### `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
}
'
```

### 使用

使用方式与 [nonebot-plugin-memes](https://github.com/noneplugin/nonebot-plugin-memes) 基本一致

