chore: 通知优化

pull/409/head
xiaojunnuo 2025-05-29 23:31:39 +08:00
parent a9b302e38d
commit 81282a9c88
3 changed files with 13 additions and 10 deletions

View File

@ -203,6 +203,7 @@ export class RunnableCollection {
if (runnable?.status) {
runnable.status.status = ResultType.none;
runnable.status.result = ResultType.none;
runnable.status.output = {};
runnable.status.inputHash = "";
// @ts-ignore
runnable.input = {};

View File

@ -61,21 +61,23 @@ export class GithubCheckRelease extends AbstractTaskPlugin {
}
//插件执行方法
async execute(): Promise<void> {
async execute(): Promise<string> {
const access = await this.getAccess<GithubAccess>(this.accessId);
const res = await access.getRelease({repoName:this.repoName})
if(res == null){
throw new Error(`获取${this.repoName}最新版本失败`)
}
const lastVersion = this.ctx.lastStatus?.status?.output?.lastVersion;
if(res.tag_name == null || res.tag_name ==lastVersion){
this.logger.info(`暂无更新,${res.tag_name}`);
return
return "skip"
}
//有更新
this.logger.info(`有更新,${lastVersion}->${res.tag_name}`)
this.logger.info(`有更新,${lastVersion??"0"}->${res.tag_name}`)
this.lastVersion = res.tag_name;
const body = res.body.replaceAll("* ","- ")
//发送通知
for (const notificationId of this.notificationIds) {
await this.ctx.notificationService.send({
@ -85,7 +87,7 @@ export class GithubCheckRelease extends AbstractTaskPlugin {
logger: this.logger,
body: {
title: `${this.repoName} 新版本 ${this.lastVersion} 发布`,
content: `${res.body}\n\n >Certd不止证书自动化,插件解锁无限可能!`,
content: `${body}\n\n > [Certd](https://certd.docmirror.cn)不止证书自动化,插件解锁无限可能!\n\n`,
url: `https://github.com/${this.repoName}/releases/tag/${this.lastVersion}`,
}
})

View File

@ -55,14 +55,14 @@ export class QywxNotification extends BaseNotification {
* }
* }
*/
const color = body.errorMessage?'red':'green';
await this.http.request({
url: this.webhook,
method: 'POST',
data: {
msgtype: 'text',
text: {
content: `${body.title}\n${body.content}\n查看详情: ${body.url}`,
msgtype: 'markdown',
markdown: {
content: `<font color='${color}'>${body.title}</font>\n\n\n${body.content}\n\n[查看详情](${body.url})`,
mentioned_list: this.mentionedList,
mentioned_mobile_list: this.mentionedMobileList,
},