🥅
This commit is contained in:
@@ -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,
|
||||
// 图片
|
||||
|
||||
@@ -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(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
|
||||
.replace(/___+/, `<title color="#777777" size="26">${title}</title>`)
|
||||
|
||||
return forwardMsg
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理更新失败的相关函数
|
||||
* @param {string} err
|
||||
|
||||
@@ -149,8 +149,10 @@ export default new class {
|
||||
* @param {Boolean} [options.xmlTitle] - XML 标题
|
||||
* @param {Boolean} [options.oneMsg] - 用于只有一条消息,不用再转成二维数组
|
||||
* @param {Boolean | import('icqq').Anonymous} [options.anony] - 匿名消息,若为true则发送匿名消息
|
||||
* @returns {Promise<import('icqq').MessageRet>} 消息发送结果的Promise对象
|
||||
* @param {Boolean} [options.shouldSendMsg=true] - 是否直接发送消息,true为直接发送,否则返回需要发送的消息
|
||||
* @returns {Promise<import('icqq').MessageRet|import('icqq').XmlElem|import('icqq').JsonElem>} 消息发送结果的Promise对象
|
||||
*/
|
||||
|
||||
async getforwardMsg (e, message, {
|
||||
recallMsg = 0,
|
||||
info,
|
||||
@@ -158,7 +160,8 @@ export default new class {
|
||||
isxml,
|
||||
xmlTitle,
|
||||
oneMsg,
|
||||
anony
|
||||
anony,
|
||||
shouldSendMsg = true
|
||||
} = {}) {
|
||||
let forwardMsg = []
|
||||
if (_.isEmpty(message)) throw Error('[Yenai-Plugin][sendforwardMsg][Error]发送的转发消息不能为空')
|
||||
@@ -176,21 +179,35 @@ export default new class {
|
||||
} else {
|
||||
forwardMsg = await e.friend.makeForwardMsg(forwardMsg)
|
||||
}
|
||||
if (isxml) {
|
||||
|
||||
if (isxml && typeof (forwardMsg.data) !== 'object') {
|
||||
// 处理转发卡片
|
||||
forwardMsg.data = forwardMsg.data.replace('<?xml version="1.0" encoding="utf-8"?>', '<?xml version="1.0" encoding="utf-8" ?>')
|
||||
}
|
||||
|
||||
if (xmlTitle) {
|
||||
forwardMsg.data = forwardMsg.data.replace(/\n/g, '')
|
||||
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
|
||||
.replace(/___+/, `<title color="#777777" size="26">${xmlTitle}</title>`)
|
||||
if (typeof (forwardMsg.data) === 'object') {
|
||||
let detail = forwardMsg.data?.meta?.detail
|
||||
if (detail) {
|
||||
detail.news = [{ text: xmlTitle }]
|
||||
}
|
||||
} else {
|
||||
forwardMsg.data = forwardMsg.data
|
||||
.replace(/\n/g, '')
|
||||
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
|
||||
.replace(/___+/, `<title color="#777777" size="26">${xmlTitle}</title>`)
|
||||
}
|
||||
}
|
||||
if (shouldSendMsg) {
|
||||
let msgRes = await this.reply(e, forwardMsg, false, {
|
||||
anony,
|
||||
fkmsg,
|
||||
recallMsg
|
||||
})
|
||||
return msgRes
|
||||
} else {
|
||||
return forwardMsg
|
||||
}
|
||||
let msgRes = await this.reply(e, forwardMsg, false, {
|
||||
anony,
|
||||
fkmsg,
|
||||
recallMsg
|
||||
})
|
||||
return msgRes
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user