diff --git a/apps/update.js b/apps/update.js
new file mode 100644
index 0000000..010a1e2
--- /dev/null
+++ b/apps/update.js
@@ -0,0 +1,76 @@
+import { Update, plugin, common } from 'node-karin'
+import { Restart, makeForwardMsg } from '#lib'
+import { Version } from '#components'
+import _ from 'lodash'
+
+let uping = false
+export class MusicUpdate extends plugin {
+ constructor () {
+ super({
+ name: '更新',
+ event: 'message',
+ priority: 1000,
+ rule: [
+ {
+ reg: '^#?铃(插件)?(强制)?更新$',
+ fnc: 'update',
+ permission: 'master'
+ },
+ {
+ reg: '^#?铃(插件)?更新日志$',
+ fnc: 'update_log',
+ permission: 'master'
+ }
+ ]
+ })
+ }
+
+ async update (e = this.e) {
+ if (uping) {
+ e.reply(`正在更新${Version.pluginName},请稍后...`)
+ return false
+ }
+ uping = true
+ setTimeout(() => {
+ uping = false
+ }, 300 * 1000)
+
+ let [ name, cmd ] = [ Version.pluginName, 'git pull' ]
+ if (e.msg.includes('强制')) cmd = 'git reset --hard && git pull --allow-unrelated-histories'
+ try {
+ const { data } = await Update.update(Version.pluginPath, cmd)
+ const msg = `更新${name}...${_.isObject(data) ? `${data.message}\n${data.stderr}` : data}`
+ await this.replyForward(common.makeForward(msg))
+ if (!data.includes('更新成功')) return true
+ try {
+ await this.reply(`\n更新完成,开始重启 本次运行时间:${common.uptime()}`, { at: true })
+ const restart = new Restart(e)
+ restart.e = e
+ await restart.CmdRestart()
+ return true
+ } catch (error) {
+ return e.reply(`${Version.pluginName}重启失败,请手动重启以应用更新!`)
+ }
+ } catch (error) {
+ return e.reply(`更新失败:${error.message}`, { at: true })
+ } finally {
+ uping = false
+ }
+ return true
+ }
+
+ async update_log (e = this.e) {
+ try {
+ const data = (await Update.getCommit({ path: Version.pluginPath, count: 10 })).replace(/\n\s*\n/g, '\n')
+ const commitlist = data
+ .split('\n')
+ .filter(Boolean)
+ .map((item) => item.trimEnd())
+ e.reply(await makeForwardMsg(e, commitlist))
+ return true
+ } catch {
+ await e.reply(`\n获取更新日志失败:\n${e.msg}`, { at: true })
+ return true
+ }
+ }
+}
diff --git a/lib/index.js b/lib/index.js
index b1fd90d..a359b00 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1,3 +1,5 @@
import puppeteer from './puppeteer.js'
+import Restart from './restart.js'
+import makeForwardMsg from './makeForwardMsg.js'
-export { puppeteer }
+export { puppeteer, Restart, makeForwardMsg }
diff --git a/lib/makeForwardMsg.js b/lib/makeForwardMsg.js
new file mode 100644
index 0000000..4d08c00
--- /dev/null
+++ b/lib/makeForwardMsg.js
@@ -0,0 +1,10 @@
+import { Version } from '#components'
+import common from 'node-karin'
+
+const makeForwardMsg = await (async () => {
+ return async (e, elements) => {
+ return common.makeForward(elements, e.self_id, e.sender.name || e.sender.nick)
+ }
+})()
+
+export default makeForwardMsg
diff --git a/lib/restart.js b/lib/restart.js
new file mode 100644
index 0000000..46375ac
--- /dev/null
+++ b/lib/restart.js
@@ -0,0 +1,18 @@
+import fs from 'fs'
+import path from 'path'
+import { pathToFileURL } from 'url'
+import { Version } from '#components'
+
+const Restart = await (async () => {
+ const baseRestartPath = path.join(process.cwd(), 'plugins/karin-plugin-basic/apps/restart.js')
+ if (fs.existsSync(baseRestartPath)) {
+ const restartUrl = pathToFileURL(baseRestartPath).href
+ const { Restart } = await import(restartUrl)
+ return Restart
+ } else {
+ logger.error('未安装karin-plugin-basic (https://github.com/KarinJS/karin-plugin-basic),无法提供重启支持,请安装后重试!')
+ return false
+ }
+})()
+
+export default Restart
diff --git a/resources/help/changelogs.html b/resources/help/changelogs.html
index b71c7e5..db1d109 100644
--- a/resources/help/changelogs.html
+++ b/resources/help/changelogs.html
@@ -1277,59 +1277,38 @@
- 1.1.2 (2024-08-13)
-Bug Fixes
+ 更新日志
+1.3.0 (2024-08-27)
+Features
-1.1.1 (2024-08-13)
Bug Fixes
-1.1.0 (2024-08-05)
+1.2.0 (2024-08-26)
Features
Bug Fixes
-1.0.1 (2024-08-04)
+1.1.5 (2024-08-19)
Bug Fixes
-1.0.0 (2024-08-04)
-Features
+1.1.4 (2024-08-18)
+Bug Fixes