!69 add:#喵喵更新日志

Merge pull request !69 from 小花花花儿/N/A
This commit is contained in:
Kokomi 2024-01-30 20:15:21 +00:00 committed by Gitee
commit e39dcb13ff
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -2,6 +2,8 @@ import fs from 'node:fs'
import lodash from 'lodash' import lodash from 'lodash'
import { exec } from 'child_process' import { exec } from 'child_process'
import { Cfg, Common, Data, Version, App } from '#miao' import { Cfg, Common, Data, Version, App } from '#miao'
import makemsg from "../../../lib/common/common.js"
import { execSync } from "child_process";
import fetch from 'node-fetch' import fetch from 'node-fetch'
let keys = lodash.map(Cfg.getCfgSchemaMap(), (i) => i.key) let keys = lodash.map(Cfg.getCfgSchemaMap(), (i) => i.key)
@ -24,6 +26,11 @@ app.reg({
fn: updateMiaoPlugin, fn: updateMiaoPlugin,
desc: '【#管理】喵喵更新' desc: '【#管理】喵喵更新'
}, },
updatelog: {
rule: /^#?喵喵更新日志$/,
fn: Miaoupdatelog,
desc: '【#管理】喵喵更新'
},
sysCfg: { sysCfg: {
rule: sysCfgReg, rule: sysCfgReg,
fn: sysCfg, fn: sysCfg,
@ -51,7 +58,7 @@ const checkAuth = async function (e) {
return true return true
} }
async function sysCfg (e) { async function sysCfg(e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true return true
} }
@ -92,7 +99,7 @@ async function sysCfg (e) {
}, { e, scale: 1.4 }) }, { e, scale: 1.4 })
} }
async function updateRes (e) { async function updateRes(e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true return true
} }
@ -136,7 +143,7 @@ async function updateRes (e) {
let timer let timer
async function updateMiaoPlugin (e) { async function updateMiaoPlugin(e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true return true
} }
@ -184,7 +191,36 @@ async function updateMiaoPlugin (e) {
return true return true
} }
async function miaoApiInfo (e) { async function Miaoupdatelog(e, plugin = 'miao-plugin') {
let cm = 'git log -20 --oneline --pretty=format:"%h||[%cd] %s" --date=format:"%F %T"'
if (plugin) {
cm = `cd ./plugins/${plugin}/ && ${cm}`
}
let logAll
try {
logAll = await execSync(cm, { encoding: 'utf-8', windowsHide: true })
} catch (error) {
logger.error(error.toString())
this.reply(error.toString())
}
if (!logAll) return false
logAll = logAll.split('\n')
let log = []
for (let str of logAll) {
str = str.split('||')
if (str[0] == this.oldCommitId) break
if (str[1].includes('Merge branch')) continue
log.push(str[1])
}
let line = log.length
log = log.join('\n\n')
if (log.length <= 0) return ''
let end = '更多详细信息请前往gitee查看\nhttps://gitee.com/yoimiya-kokomi/miao-plugin'
log = await makemsg.makeForwardMsg(this.e, [log, end], `${plugin}更新日志,共${line}`)
e.reply(log)
}
async function miaoApiInfo(e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true return true
} }
@ -202,4 +238,4 @@ async function miaoApiInfo (e) {
return e.reply('token检查错误请求失败') return e.reply('token检查错误请求失败')
} }
e.reply(data.msg) e.reply(data.msg)
} }