From ce9449b781214728b4be4d97fba02e014c15f04d Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Tue, 14 Mar 2023 16:11:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20refactor:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/daily.js | 99 --------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 apps/daily.js diff --git a/apps/daily.js b/apps/daily.js deleted file mode 100644 index 5791794..0000000 --- a/apps/daily.js +++ /dev/null @@ -1,99 +0,0 @@ -import fetch from "node-fetch"; -import { Group, segment } from "oicq"; -import { autoTask } from "../utils/common.js"; - -// 指定定时发送的群号 -const groupList = ["169721415"]; - -// 是否开启定时推送,默认为 true -let isAutoPush = false; - -// 定时任务合集 -autoTask(pushDailyWorld, "0 30 8 * * ?", groupList, isAutoPush); -autoTask(pushTouchFish, "0 31 8 * * ?", groupList, isAutoPush); - -export class daily extends plugin { - constructor(e) { - super({ - name: "R插件每日任务", - dsc: "R插件每日任务", - event: "message", - priority: 500, - rule: [ - { - reg: "^#每天60秒$", - fnc: "dailyWorld", - }, - { - reg: "^#摸鱼人日历$", - fnc: "touchFish", - }, - { - reg: "^#开关每日推送$", - fnc: "shutdown", - }, - ], - }); - } - - async dailyWorld(e) { - // 定时发送时间,采用 Cron 表达式,当前默认为每日 8:30 分推送 - await pushDailyWorld(e); - return true; - } - - async touchFish(e) { - await pushTouchFish(e); - return true; - } - - async shutdown(e) { - isAutoPush = !isAutoPush; - e.reply(`【当前推送状态】:${isAutoPush ? "开启" : "关闭"}`); - } -} - -/** - * 推送每天60秒读懂世界 - * @param e oicq传递的事件参数e - */ -async function pushDailyWorld(e) { - // 每天60秒读懂世界接口地址 - const url = await fetch("https://api.vvhan.com/api/60s?type=json").catch(err => - console.error(err), - ); - const imgUrl = await url.json(); - 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 => - console.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)); - } else { - e.reply(segment.image(res)); - } -}