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


Release history Release notifications | RSS feed

This version

1.0

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.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

nonebot_plugin_wenan-1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_plugin_wenan-1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for nonebot_plugin_wenan-1.0.tar.gz
Algorithm Hash digest
SHA256 24c81c0f7a34ecab58a1b7d823b913b36e6d1329e120a725054b055b4c4945ca
MD5 e2f74565fe089e2b6964a3c7034d354a
BLAKE2b-256 ad02b194da54e941df19515684264f4f3cf14bfa77c7caf7e13e08b906b1c2b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_wenan-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc2be67110bceb551a4ad34c6480840c6d96f5574f66b8b3909c48a774dcca9
MD5 16173c969a43ffe44a36f6a84403b2cb
BLAKE2b-256 9bb8312f32373574657b992291934039b097a5a6776b1d5308e933e1cbcaa403

See more details on using hashes here.

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