Skip to main content

Nonebot2 通用抽图/语音插件

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-random

✨ Nonebot2 通用抽图/语音插件 ✨

license pypi python

📖 介绍

如果只是想简单做个抽图或者抽语音的功能,不需要自己写多余的代码

只需要安装本插件,在对应路径放好相关资源并配置好即可

💿 安装

插件仍在开发中,遇到问题还请务必提 issue。

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-random
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-random
pdm
pdm add nonebot-plugin-random
poetry
poetry add nonebot-plugin-random
conda
conda install nonebot-plugin-random

打开 nonebot2 项目的 bot.py 文件, 在其中写入

nonebot.load_plugin('nonebot_plugin_random')
从 github 安装 在 nonebot2 项目的插件目录下, 打开命令行, 输入以下命令克隆此储存库
git clone https://github.com/jcjrobert/nonebot-plugin-random.git

打开 nonebot2 项目的 bot.py 文件, 在其中写入

nonebot.load_plugin('src.plugins.nonebot_plugin_random')

🎉 使用

机器人每次在重启时会创建(如果没有)并读取机器人运行目录下的 data/random/ 文件夹

然后依次读取每个文件夹,一个文件夹就是一个抽取功能

以随机capoo为例,你可以在 data/random 下创建capoo文件夹,然后把你喜欢的capoo图片放入文件夹

之后重启,使用命令 随机capoo 即可

⚙️ 配置

如果你有自定义命令的需求,你可以在当前文件夹,以随机capoo为例

data/random/capoo下添加config.json文件,然后按照下表进行配置并重启

配置项 必填 默认值 说明
"draw_output" "image" 抽取输出类型,有"image"/"record"
"draw_mode" "direct" 抽取方式,"direct"表示直接从当前文件夹抽取,"indirect"表示随机从当前文件夹抽取一个文件夹然后从该文件夹抽取
"message_type" "command" 命令响应类型,"command"即on_command,"keyword"即on_keyword, "regex"即on_regex
"message" ["随机当前文件夹文件名"] 自定义命令,必须是列表,若"message_type"为"keyword"时只取第一项,为"regex"时必须为两项,第一项是正则表达式,第二项是匹配表达式的命令
"is_tome" false 使用抽取命令时是否需要at机器人
"output_prefix" "" 输出前缀,"draw_output"为"record"下该配置无效
"output_suffix" "" 输出后缀,"draw_output"为"record"下该配置无效
"is_at_sender" false 机器人发消息时是否需要at发送者,"draw_output"为"record"下该配置无效

📝 TODO LIST

  • 对随机命令进行开关管理
  • 支持文本抽取
  • 菜单生成
  • 优化代码结构(先保证能跑)

📝 更新日志

展开/收起

0.0.1

  • 插件初次发布

0.0.2

  • 修复未配置"message"时不能正常使用随机命令的bug
  • 支持输出前后缀配置和at发送者

0.0.3

  • 支持正则命令匹配

💡 特别感谢

其他

capoo资源请自行网上查找(((

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot-plugin-random-0.0.3.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

nonebot_plugin_random-0.0.3-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page