mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-14 12:17:48 +00:00
feat: 日历
This commit is contained in:
parent
7ebb5b40d1
commit
7d9f33fa49
3 changed files with 59 additions and 1 deletions
|
|
@ -1,3 +1,8 @@
|
|||
# 1.5.2
|
||||
* 新增“日历”功能。
|
||||
* 修复了图片错误问题。
|
||||
* 修复了角色查询问题。
|
||||
|
||||
# 1.5.1
|
||||
* 新增“月报”功能,即查看菲林、邦布券、母带的获取情况,发送 `%帮助` 查看如何使用
|
||||
|
||||
|
|
|
|||
52
apps/calendar.js
Normal file
52
apps/calendar.js
Normal file
|
|
@ -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 = /<img.*?src="(.*?)".*?>/g;
|
||||
const imgSrc = imgReg.exec(htmlContent)?.[1];
|
||||
if (imgSrc) {
|
||||
await this.reply(segment.image(imgSrc));
|
||||
} else {
|
||||
await this.reply('未找到活动日历图片');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,4 +9,5 @@ panel: 70 # 面板
|
|||
update: 70 # 更新
|
||||
user: 70 # 账号操作
|
||||
monthly: 70 # 菲林月历
|
||||
code: 70 # 兑换码
|
||||
code: 70 # 兑换码
|
||||
calendar: 70 # 日历
|
||||
Loading…
Add table
Add a link
Reference in a new issue