From f55033a20c58b24197496f9587c3b5701cd21f42 Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Wed, 4 Jan 2023 12:04:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=A2=9E=E5=8A=A0=E6=91=B8?= =?UTF-8?q?=E9=B1=BC=E4=BA=BA=E6=97=A5=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 更改README.md 2. 修复一些问题 3. 增加每日推送 --- README.md | 5 ++--- apps/daily.js | 39 ++++++++++++++++++++++++++++++++++----- apps/tools.js | 15 +++++++++------ 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e48f8d2..c4ee263 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,9 @@ index -- 主入口 > linux系统下自己装一个mongodb,上一个密码(不上有风险) 2. `test -- main.py`爬取链接(要有python环境、配合mongodb使用) > python3 main.py -4. 在`Yunzai-Bot`安装mongodb、axios(0.27.2)依赖 -> pnpm add mongodb -w +4. 在`Yunzai-Bot`安装mongodb、axios(0.27.2)、代理工具(tunnel)、TwitterAPI依赖 +> pnpm add mongodb axios tunnel twitter-api-v2 -w -> pnpm add axios -w 4. 下载插件 > git clone https://gitee.com/kyrzy0416/rconsole-plugin.git ./plugins/rconsole-plugin/ diff --git a/apps/daily.js b/apps/daily.js index 6e73f89..3112cd6 100644 --- a/apps/daily.js +++ b/apps/daily.js @@ -22,6 +22,7 @@ function autoTask (func, time) { // 定时任务合集 autoTask(pushDailyWorld, '0 30 8 * * ?') +autoTask(pushTouchFish, '0 31 8 * * ?') export class daily extends plugin { constructor (e) { @@ -33,7 +34,11 @@ export class daily extends plugin { rule: [ { reg: '^#每天60秒$', - fnc: 'pushDailyWorld' + fnc: 'dailyWorld' + }, + { + reg: '^#摸鱼人日历$', + fnc: 'touchFish' }, { reg: '^#开关每日推送$', @@ -45,8 +50,13 @@ export class daily extends plugin { async dailyWorld (e) { // 定时发送时间,采用 Cron 表达式,当前默认为每日 8:30 分推送 - await pushDailyWorld(e) - return true + await pushDailyWorld(e); + return true; + } + + async touchFish (e) { + await pushTouchFish(e); + return true; } async shutdown (e) { @@ -61,16 +71,35 @@ export class daily extends plugin { */ async function pushDailyWorld (e) { // 每天60秒读懂世界接口地址 - const url = await fetch('http://bjb.yunwj.top/php/tp/lj.php') + const url = await fetch('https://api.vvhan.com/api/60s?type=json') .catch(err => logger.error(err)) const imgUrl = await url.json() - const res = await imgUrl.tp + const res = await imgUrl.imgUrl // 判断接口是否请求成功 if (!res) { e.reply('[60秒读懂世界] 接口请求失败') } + // 回复消息 + if (e instanceof Group) { + e.sendMsg(segment.image(res)) + } else { + e.reply(segment.image(res)) + } +} + +async function pushTouchFish (e) { + const url = await fetch('https://api.vvhan.com/api/moyu?type=json') + .catch(err => logger.error(err)) + const imgUrl = await url.json() + const res = await imgUrl.url + + // 判断接口是否请求成功 + if (!res) { + e.reply('[摸鱼人日历] 接口请求失败') + } + // 回复消息 if (e instanceof Group) { e.sendMsg(segment.image(res)) diff --git a/apps/tools.js b/apps/tools.js index d0fd08e..7cb9e6d 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -252,13 +252,16 @@ export class tools extends plugin { e.reply(`识别:腿忒学习版,${resp.data.text}`) const downloadPath = `${ this.defaultPath }${ this.e.group_id || this.e.user_id }`; if (resp.includes.media[0].type === 'photo') { + // 目前解决方案:express建立本地请求,然后segment.image,但是要引入express + e.reply("目前想到的解决方案较为复杂,待解决!"); + return true; // 图片 - resp.includes.media.map(item => { - const filePath = `${downloadPath}/${item.url.split('/').pop()}` - this.downloadImgs(item.url, downloadPath).then(res => { - e.reply([segment.image(filePath)]) - }) - }) + // resp.includes.media.map(item => { + // const filePath = `${downloadPath}/${item.url.split('/').pop()}` + // this.downloadImgs(item.url, downloadPath).then(res => { + // e.reply([segment.image(filePath)]) + // }) + // }) } else { // 视频 this.downloadVideo(resp.includes.media[0].variants[0].url, true).then(video => {