From 7d9f33fa496c49136f0c925c8b4b67b9c9d5cc9d Mon Sep 17 00:00:00 2001 From: bietiaop <1527109126@qq.com> Date: Fri, 15 Nov 2024 20:06:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=97=A5=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ apps/calendar.js | 52 ++++++++++++++++++++++++++++++++++++++++++++ defSet/priority.yaml | 3 ++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 apps/calendar.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5f8cf..2984ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.5.2 +* 新增“日历”功能。 +* 修复了图片错误问题。 +* 修复了角色查询问题。 + # 1.5.1 * 新增“月报”功能,即查看菲林、邦布券、母带的获取情况,发送 `%帮助` 查看如何使用 diff --git a/apps/calendar.js b/apps/calendar.js new file mode 100644 index 0000000..6dff089 --- /dev/null +++ b/apps/calendar.js @@ -0,0 +1,52 @@ +import { ZZZPlugin } from '../lib/plugin.js'; +import settings from '../lib/settings.js'; +import _ from 'lodash'; +import { rulePrefix } from '../lib/common.js'; +import request from '../utils/request.js'; + +export class Note extends ZZZPlugin { + constructor() { + super({ + name: '[ZZZ-Plugin]Calendar', + dsc: 'zzzCalendar', + event: 'message', + priority: _.get(settings.getConfig('priority'), 'calendar', 70), + rule: [ + { + reg: `${rulePrefix}(cal|日历)$`, + fnc: 'calendar', + }, + ], + }); + } + async calendar() { + const activityList = await request.get( + 'https://announcement-api.mihoyo.com/common/nap_cn/announcement/api/getAnnList?game=nap&game_biz=nap_cn&lang=zh-cn&bundle_id=nap_cn&channel_id=1&level=70&platform=pc®ion=prod_gf_cn&uid=12345678' + ); + if (!activityList?.data) { + await this.reply('获取活动列表失败'); + return false; + } + const t = activityList?.data?.t || new Date().getTime().toString(); + const activityContent = await request.get( + `https://announcement-static.mihoyo.com/common/nap_cn/announcement/api/getAnnContent?game=nap&game_biz=nap_cn&lang=zh-cn&bundle_id=nap_cn&platform=pc®ion=prod_gf_cn&t=${t}&level=70&channel_id=1` + ); + const contentList = activityContent?.data?.list || []; + const calendarContent = contentList.find( + item => item.title.includes('日历') && item.subtitle.includes('活动日历') + ); + const htmlContent = calendarContent?.content || ''; + if (!htmlContent) { + await this.reply('未找到活动日历'); + return false; + } + const imgReg = //g; + const imgSrc = imgReg.exec(htmlContent)?.[1]; + if (imgSrc) { + await this.reply(segment.image(imgSrc)); + } else { + await this.reply('未找到活动日历图片'); + } + return false; + } +} diff --git a/defSet/priority.yaml b/defSet/priority.yaml index 4f7b44f..2ad78dd 100644 --- a/defSet/priority.yaml +++ b/defSet/priority.yaml @@ -9,4 +9,5 @@ panel: 70 # 面板 update: 70 # 更新 user: 70 # 账号操作 monthly: 70 # 菲林月历 -code: 70 # 兑换码 \ No newline at end of file +code: 70 # 兑换码 +calendar: 70 # 日历 \ No newline at end of file