diff --git a/apps/state.js b/apps/state.js index 7e31f5e..15a52c9 100644 --- a/apps/state.js +++ b/apps/state.js @@ -86,7 +86,7 @@ export class NewState extends plugin { // 头像 portrait: e.bot?.avatar ?? `https://q1.qlogo.cn/g?b=qq&s=0&nk=${this.Bot.uin}`, // 运行时间 - runTime: common.formatTime(Date.now() / 1000 - this.Bot.stat.start_time, 'dd天hh小时mm分', false), + runTime: common.formatTime(Date.now() / 1000 - this.Bot.stat?.start_time, 'dd天hh小时mm分', false), // 日历 calendar: moment().format('YYYY-MM-DD HH:mm:ss'), // 昵称 @@ -94,7 +94,7 @@ export class NewState extends plugin { // 系统运行时间 systime: common.formatTime(os.uptime(), 'dd天hh小时mm分', false), // 收 - recv: this.Bot.stat.recv_msg_cnt, + recv: this.Bot.stat?.recv_msg_cnt, // 发 sent: await redis.get('Yz:count:sendMsg:total') || 0, // 图片 diff --git a/apps/update.js b/apps/update.js index 470665f..17be63e 100644 --- a/apps/update.js +++ b/apps/update.js @@ -2,6 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js' import { createRequire } from 'module' import _ from 'lodash' import { Restart } from '../../other/restart.js' +import common from '../lib/common/common.js' const require = createRequire(import.meta.url) const { exec, execSync } = require('child_process') @@ -138,8 +139,12 @@ export class Update extends plugin { let end = '' end = '更多详细信息,请前往gitee查看\nhttps://gitee.com/yeyang52/yenai-plugin/blob/master/CHANGELOG.md' - - log = await this.makeForwardMsg(`椰奶插件更新日志,共${line}条`, log, end) + let forwardMsg = [ + `椰奶插件更新日志,共${line}条`, log, end + ] + log = await common.getforwardMsg(this.e, forwardMsg, { + shouldSendMsg: false + }) return log } @@ -177,58 +182,6 @@ export class Update extends plugin { return time } - /** - * 制作转发消息 - * @param {string} title 标题 - 首条消息 - * @param {string} msg 日志信息 - * @param {string} end 最后一条信息 - * @returns - */ - async makeForwardMsg (title, msg, end) { - let nickname = (this.e.bot ?? Bot).nickname - if (this.e.isGroup) { - let info = await (this.e.bot ?? Bot).getGroupMemberInfo(this.e.group_id, (this.e.bot ?? Bot).uin) - nickname = info.card || info.nickname - } - let userInfo = { - user_id: (this.e.bot ?? Bot).uin, - nickname - } - - let forwardMsg = [ - { - ...userInfo, - message: title - }, - { - ...userInfo, - message: msg - } - ] - - if (end) { - forwardMsg.push({ - ...userInfo, - message: end - }) - } - - /** 制作转发内容 */ - if (this.e.isGroup) { - forwardMsg = await this.e.group.makeForwardMsg(forwardMsg) - } else { - forwardMsg = await this.e.friend.makeForwardMsg(forwardMsg) - } - - /** 处理描述 */ - forwardMsg.data = forwardMsg.data - .replace(/\n/g, '') - .replace(/