mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-15 03:23:22 +08:00
* feat(ActivitySwitchNotice): 添加地图任务识别功能 - 新增 mapMission 工具模块用于OCR地图任务识别 - 在初始化工具列表中加入 mapMission 模块 - 修改 main 函数增加异常处理和开关控制逻辑 - 优化代码格式和缩进一致性 - 添加地图任务OCR识别区域配置参数 * feat(ActivitySwitchNotice): 添加地图任务识别功能并优化配置管理 - 实现地图任务识别功能,支持伴月纪闻任务和每日委托奖励识别 - 新增initSettings函数用于统一管理配置文件读取和初始化 - 在settings.json中添加地图任务相关的多选框配置选项 - 更新manifest.json版本至0.0.8并添加最低BGI版本要求 - 重构ocrMapMission函数以支持多任务名称匹配 - 添加openMap和mapMission工具函数用于地图操作和任务识别 - 优化通知系统,移除不必要的参数并完善错误处理 - 调整设置界面布局,添加分隔符提升用户体验 * feat(map): 添加地图任务识别功能 - 实现多复选框配置映射表获取功能 - 添加根据复选框名称获取对应值的方法 - 重构OCR地图任务识别函数,优化参数和错误处理 - 集成UID识别并在通知中显示 - 更新地图任务识别流程和结果显示格式 - 添加地图任务识别数量统计日志 - 在README中更新版本历史记录 * feat(map): 添加地图任务识别功能 - 实现多复选框配置映射表获取功能 - 添加根据复选框名称获取对应值的方法 - 重构OCR地图任务识别函数,优化参数和错误处理 - 集成UID识别并在通知中显示 - 更新地图任务识别流程和结果显示格式 - 添加地图任务识别数量统计日志 - 在README中更新版本历史记录 * feat(ActivitySwitchNotice): 添加新的活动任务选项并设置默认值 - 添加探索派遣奖励选项 - 添加豪斗旅纪奖励选项 - 设置伴月纪闻任务为默认选项之一 - 设置探索派遣奖励为默认选项之一 - 设置每日委托奖励为默认选项之一 - 更新配置结构以支持多选默认值
90 lines
3.0 KiB
JavaScript
90 lines
3.0 KiB
JavaScript
const NoticeType = Object.freeze({
|
||
bgi: 'bgi',//BGI通知
|
||
independence: 'independence',//独立通知
|
||
fromValue(value) {
|
||
return Object.keys(this).find(key => this[key] === value);
|
||
}
|
||
})
|
||
const NoticeMap = new Map([
|
||
['BGI通知', [{type: NoticeType.bgi}]],
|
||
['独立通知', [{type: NoticeType.independence}]],
|
||
['独立通知和BGI通知', [{type: NoticeType.independence}, {type: NoticeType.bgi}]],
|
||
])
|
||
const configNotice = {
|
||
noticeList: NoticeMap.get(settings.noticeType),
|
||
}
|
||
|
||
/**
|
||
* 发送通知的异步函数
|
||
* @param {Map} map - 包含通知内容键值对的Map对象
|
||
* @param {string} title - 通知的标题
|
||
* @param {boolean} noNotice - 是否不发送通知的标志
|
||
*/
|
||
async function sendNotice(map = new Map(), title, noNotice = false) {
|
||
log.debug(`sendNotice: map.size=${map.size}, noNotice=${noNotice}`);
|
||
|
||
// 如果设置了不发送通知且map为空,则记录日志并返回
|
||
if ((map.size <= 0) || noNotice) {
|
||
log.debug(`if sendNotice: map.size=${map.size}, noNotice=${noNotice}`);
|
||
log.info(`[sendNotice]无通知内容`)
|
||
return
|
||
}
|
||
// 按剩余小时升序排序(即将结束的在前)
|
||
const sortedEntries = Array.from(map.entries())
|
||
.sort((a, b) => a[1].hours - b[1].hours);
|
||
|
||
let noticeText = title ? title + "\n======\n" : "\n"
|
||
for (const [name, info] of sortedEntries) {
|
||
let common = info.common
|
||
common = common ? `(${common})` : ''
|
||
noticeText += `> ${common} ${name} ${info.text} (还剩 ${info.hours} 小时) ${info.desc}\n----\n`;
|
||
}
|
||
log.debug(`sendNotice: noticeText:{noticeText}`,noticeText);
|
||
// 发送通知
|
||
for (let noticeElement of configNotice.noticeList) {
|
||
switch (noticeElement.type) {
|
||
case NoticeType.independence:
|
||
await wsUtil.sendText(noticeText)
|
||
break
|
||
case NoticeType.bgi:
|
||
notification.send(noticeText)
|
||
break
|
||
}
|
||
}
|
||
log.debug(`sendNotice: --end`);
|
||
return
|
||
}
|
||
|
||
/**
|
||
* 异步发送通知的函数
|
||
* @param {string} noticeText - 通知内容文本
|
||
* @param {string} title - 通知标题
|
||
*/
|
||
async function sendText(noticeText, title, noNotice = false) {
|
||
// 检查是否有通知内容且设置了不发送通知的标志
|
||
if ((!noticeText) || noNotice) {
|
||
log.info(`sendText 无通知内容`) // 记录日志信息
|
||
return // 直接返回,不执行后续操作
|
||
}
|
||
// 构建通知文本,如果有标题则先添加标题
|
||
let text = title ? title + "\n======\n" : "\n"
|
||
// 添加通知内容
|
||
text += noticeText
|
||
// 发送通知
|
||
for (let noticeElement of configNotice.noticeList) {
|
||
switch (noticeElement.type) {
|
||
case NoticeType.independence:
|
||
await wsUtil.sendText(text)
|
||
break
|
||
case NoticeType.bgi:
|
||
notification.send(text)
|
||
break
|
||
}
|
||
}
|
||
return
|
||
}
|
||
|
||
this.noticeUtil = {
|
||
sendNotice,
|
||
sendText,
|
||
} |