add:#喵喵更新日志

Signed-off-by: 小花花花儿 <860563585bxy@gmail.com>
This commit is contained in:
小花花花儿 2024-01-09 14:55:28 +00:00 committed by Gitee
parent 50b29402e6
commit c5a749821c
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,
@ -184,6 +191,35 @@ async function updateMiaoPlugin (e) {
return true return true
} }
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) { async function miaoApiInfo(e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true return true