From d01a515dc887e8e8a6433a0011454a474ffe769f Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Sun, 19 Feb 2023 17:34:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20style:=20=E7=BE=8E=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=EF=BC=8C=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E9=98=85=E8=AF=BB=E6=BA=90=E7=A0=81=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 4 +++- apps/update.js | 40 ++++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 9985906..7bcc7a5 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -110,7 +110,9 @@ export class tools extends plugin { // let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ transMap[language[1]] }&appid=APP ID&salt=自定义&sign=${ md5("APP ID" + place + "自定义" + "密钥") }&q=${ place }`; let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${ transMap[language[1]] - }&appid=${this.translateAppId}&salt=rconsole&sign=${md5(this.translateAppId + place + "rconsole" + this.translateSecret)}&q=${place}`; + }&appid=${this.translateAppId}&salt=rconsole&sign=${md5( + this.translateAppId + place + "rconsole" + this.translateSecret + )}&q=${place}`; // console.log(url) await fetch(url) .then(resp => resp.json()) diff --git a/apps/update.js b/apps/update.js index 14f0649..9ae8460 100644 --- a/apps/update.js +++ b/apps/update.js @@ -57,11 +57,11 @@ export class update extends plugin { const pluginName = "rconsole-plugin"; - let command = ''; + let command = ""; if (isForce) { - command = `git checkout . && git -C ./plugins/${pluginName}/ pull --no-rebase` + command = `git checkout . && git -C ./plugins/${pluginName}/ pull --no-rebase`; } else { - command = `git -C ./plugins/${pluginName}/ pull --no-rebase` + command = `git -C ./plugins/${pluginName}/ pull --no-rebase`; } this.oldCommitId = await this.getcommitId(pluginName); await e.reply("正在执行更新操作,请稍等"); @@ -139,21 +139,29 @@ export class update extends plugin { return log; } - async gitErr (err, stdout) { - let msg = '更新失败!' - let errMsg = err.toString() - stdout = stdout.toString() - if (errMsg.includes('Timed out')) { - await this.reply(msg + `\n连接超时:${errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')}`) + async gitErr(err, stdout) { + let msg = "更新失败!"; + let errMsg = err.toString(); + stdout = stdout.toString(); + if (errMsg.includes("Timed out")) { + await this.reply(msg + `\n连接超时:${errMsg.match(/'(.+?)'/g)[0].replace(/'/g, "")}`); } else if (/Failed to connect|unable to access/g.test(errMsg)) { - await this.reply(msg + `\n连接失败:${errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')}`) - } else if (errMsg.includes('be overwritten by merge')) { - await this.reply(msg + `存在冲突:\n${errMsg}\n` + '请解决冲突后再更新,或者执行#强制更新,放弃本地修改') - } else if (stdout.includes('CONFLICT')) { - await this.reply([msg + '存在冲突\n', errMsg, stdout, '\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改']) + await this.reply(msg + `\n连接失败:${errMsg.match(/'(.+?)'/g)[0].replace(/'/g, "")}`); + } else if (errMsg.includes("be overwritten by merge")) { + await this.reply( + msg + + `存在冲突:\n${errMsg}\n` + + "请解决冲突后再更新,或者执行#强制更新,放弃本地修改" + ); + } else if (stdout.includes("CONFLICT")) { + await this.reply([ + msg + "存在冲突\n", + errMsg, + stdout, + "\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改", + ]); } else { - await this.reply([errMsg, stdout]) + await this.reply([errMsg, stdout]); } } - }