Skip to main content

No project description provided

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-wenan

✨ 一款可以自由增删文案指令和api的插件 ✨

license pypi python

📖 介绍

在我调用各种文案api的时候,觉得每个api取一个指令并写一个小插件太麻烦了,因此写了本插件,只需配置yml即可增添文案api以及触发指令,如下图所示:

image

💿 安装

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

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot-plugin-wenan"]

⚙️ 配置

本插件的配置在bot根目录下的config文件夹下,名为wenan_api_config.yml,该文件会在插件第一次运行时自动生成。其内容如同介绍中的截图所示。 可参考 https://github.com/Q1351998764/nonebot-plugin-picture-api

写法如下所示:

情话|qh:
  - url: https://api.f4team.cn/API/qing/api.php
    is_proxy: false
    type: text

其中,情话|qh 代表api的触发指令,用"情话"或者是"qh"均可触发。url后跟api;is_proxy代表是否使用代理,可不写,默认false;type代表该api是否直接返回文案,可不写,默认为text

也可在一个关键词下设置多个url,如下所示:

一言:
  - url: https://api.f4team.cn/API/dmyiyan/api.php
  - url: https://api.f4team.cn/API/wryl/api.php

其中,is_proxy与image均没写,采用默认值false和text

如果api返回是json,如下所示:

一言:
  - url: https://v1.hitokoto.cn/
    path: hitokoto
    type: json

其中 https://v1.hitokoto.cn/ 接口返回的json格式如下:

{"id":6210,"uuid":"bc908f7e-9985-44d3-8234-4e0273e19672","hitokoto":"我不是畏惧风,我只是怕风把沙子吹到我的眼睛里!","type":"e","from":"日常随笔","from_who":"白凝羽","creator":"白凝羽","creator_uid":6045,"reviewer":1044,"commit_from":"app","created_at":"1590722736","length":23}

path后就需要跟路径hitokoto,指向最终图片的url,注意:返回格式为json的api,必须要写path,并最终指向图片url

一个关键词下可以设置多个url,并且返回不同类型的url也可以混合设置,如下所示:

一言:
  - url: https://v1.hitokoto.cn/
    path: hitokoto
    type: json
  -url: https://api.f4team.cn/API/dmyiyan/api.php

在上面的配置中,指令"一言"对应了两个url,第一个url返回json格式,第二个url直接返回文本。

大概配置就这样。

🎉 使用

配置完后直接对机器人发送配置的指令即可,机器人将随机调用该指令下的一个接口。

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_wenan-1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_wenan-1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_wenan-1.2.tar.gz.

File metadata

  • Download URL: nonebot_plugin_wenan-1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nonebot_plugin_wenan-1.2.tar.gz
Algorithm Hash digest
SHA256 5d8dc2995ab26f7c29786fdb43d3dbc93d8925026608479c572cd49dafd8027b
MD5 07a6170195b3e12e9bb332e725d5cb6a
BLAKE2b-256 766e81c606d9502929e2851d9c00dbbc408ea52fff6370101d059b8c49097b46

See more details on using hashes here.

File details

Details for the file nonebot_plugin_wenan-1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_wenan-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 baa87eed94c727d35af9804f50819dd264e82489a2fb6445b79e7b25a0822d00
MD5 ffda78e01ed3a05820ff64378f352fe6
BLAKE2b-256 2f2bdf7345aa6a5cd2c9014b100f321266cc8971d45412923f55ebf435b890a2

See more details on using hashes here.

Supported by

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