Skip to content

noneplugin/nonebot-plugin-memes-api

Repository files navigation

nonebot

nonebot-plugin-memes-api

Nonebot2 表情包制作插件 调用 api 版本 ✨

license Python NoneBot pypi qq group

本插件为 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

meme-generator 部署

按照 meme-generator 安装 中的说明安装,并下载图片、安装字体等

之后通过 meme run 启动 web server

配置项

以下配置项可在 .env.* 文件中设置,具体参考 NoneBot 配置方式

meme_generator_base_url

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

memes_command_prefixes

  • 类型:List[str] | None
  • 默认:None
  • 说明:命令前缀(仅作用于制作表情的命令);如果不设置默认使用 NoneBot 命令前缀

memes_disabled_list

  • 类型:List[str]
  • 默认:[]
  • 说明:禁用的表情包列表,需填写表情的key,可在 meme-generator 表情列表 中查看。若只是临时关闭,可以用下文中的“表情包开关”

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 基本一致