gdpl2112 / MiraiCallApiPlugin

一个mirai 自定义调用API的插件
GNU General Public License v3.0
19 stars 2 forks source link

自定义 调用 API 插件

下载

### 插件依赖于插件lib-tts

表达式

启动后生成配置文件

{
  //忽略https证书
  "ignoreVerify": true,
  //权限类型  有 console all  当为 console 时只能从命令调用 all 则所有都可以
  "permType": "console",
  //输入 参数分隔符
  "splitChar": " ",
  //网页管理的端口
  "port": 20042,
  //全局代理ip
  "proxyIp": null,
  //全局代理port
  "proxyPort": 0,
  //网页管理的密码
  "passwd": "123456",
  //api 调用模板
  "templates": [
  ]
}

templates 如何配置

示例涩图配置


{
  "permType": "all",
  "splitChar": " ",
  "templates": [
    {
      "err": "调用失败",
      "out": "<Pic:$1>",
      "outArgs": [
        "pic[0]"
      ],
      "proxyIp": "",
      "proxyPort": 0,
      "sw": true,
      "touch": "随机图片",
      "url": "http://api.iw233.cn/api.php?sort=cat&type=json"
    }
  ]
}

转换后内部通过转换成message

详情表达式

配置后 在群聊/好友 发送 随机图片 即可触发

复杂的返回参数

以下是 https://api.vvhan.com/api/weather?city=徐州&type=week 该 API 返回的数据 ```json { "data": { "yesterday": { "date": "30日星期三", "high": "高温 4℃", "fx": "西南风", "low": "低温 -1℃", "fl": "", "type": "雨夹雪" }, "city": "西安", "forecast": [ { "date": "31日星期四", "high": "高温 7℃", "fengli": "", "low": "低温 -6℃", "fengxiang": "西南风", "type": "小雪" }, { "date": "1日星期五", "high": "高温 7℃", "fengli": "", "low": "低温 -4℃", "fengxiang": "东北风", "type": "多云" }, { "date": "2日星期六", "high": "高温 7℃", "fengli": "", "low": "低温 -3℃", "fengxiang": "西南风", "type": "多云" }, { "date": "3日星期天", "high": "高温 10℃", "fengli": "", "low": "低温 -1℃", "fengxiang": "南风", "type": "多云" }, { "date": "4日星期一", "high": "高温 8℃", "fengli": "", "low": "低温 -3℃", "fengxiang": "东北风", "type": "多云" } ], "ganmao": "昼夜温差很大,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。", "wendu": "2" }, "status": 1000, "desc": "OK" } ```
配置文件 ```json { "permType": "all", "splitChar": " ", "templates": [ { "out": "$1:$2\n$3:$4\n$5:$6\n", "outArgs": [ "data.forecast[0].date", "data.forecast[0].type", "data.forecast[1].date", "data.forecast[1].type", "data.forecast[2].date", "data.forecast[2].type" ], "touch": "未来天气", "url": "https://api.vvhan.com/api/weather?city=$1&type=week", "err": "天气查询失败" } ] } ```

最后送上实用配置

配置文件 ```json { "passwd": "123456", "permType": "all", "port": 20042, "proxyIp": null, "proxyPort": 0, "splitChar": " ", "templates": [ { "err": "天气查询失败", "out": "\n$1:$2\n$3:$4\n$5:$6\n", "outArgs": [ "data.forecast[0].date", "data.forecast[0].type", "data.forecast[1].date", "data.forecast[1].type", "data.forecast[2].date", "data.forecast[2].type" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "未来天气", "url": "https://api.vvhan.com/api/weather?city=$1&type=week" }, { "err": "调用失败", "out": "", "outArgs": [ "pic[0]" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "随机图片", "url": "http://api.iw233.cn/api.php?sort=cat&type=json" }, { "err": "调用失败", "out": "", "outArgs": [ "$url" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "需要ta吗", "url": "https://ovooa.com/API/face_need/?QQ=$number" }, { "err": "调用失败", "out": "", "outArgs": [ "[]" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "快手图集", "url": "http://kloping.top/api/search/parseImgs?url=$1&type=ks" }, { "err": "调用失败", "out": "", "outArgs": [ "data.[]" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "堆糖搜图", "url": "http://kloping.top/api/search/pic?keyword=$1&num=3&type=duit" }, { "err": "调用失败", "out": "", "outArgs": [ "data[0].media_name", "data[0].author_name", "data[0].imgUrl", "data[0].songUrl" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "酷狗点歌", "url": "http://kloping.top/api/search/song?keyword=$1&type=kugou&n=2" }, { "err": null, "out": "\n$1", "outArgs": [ "$all" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "/ping", "url": "https://xian.txma.cn/API/sping.php?url=$1" }, { "err": null, "out": "id:$1\n来自群$2\n的$3\n时间:$call(http://kloping.top/stamp2time?stamp=$4&time=)\n昵称:$5\n信息:$6\n剩余捡起次数:$7", "outArgs": [ "id", "gid", "sid", "time", "name", "message", "state" ], "proxyIp": "", "proxyPort": 0, "sw": true, "touch": "/捡瓶子", "url": "http://kloping.top/api/pickUpBottle" } ] } ```

更多 帮助请查看 releases