细节优化
This commit is contained in:
		
							parent
							
								
									57f3741d78
								
							
						
					
					
						commit
						72d196a7d3
					
				| 
						 | 
				
			
			@ -53,7 +53,7 @@ function mkdirs (dirname) {
 | 
			
		|||
 | 
			
		||||
/**
 | 
			
		||||
 * 制作转发消息
 | 
			
		||||
 * @param e icqq消息e
 | 
			
		||||
 * @param e 消息事件
 | 
			
		||||
 * @param msg 消息数组
 | 
			
		||||
 * @param dec 转发描述
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,31 +41,29 @@ Bot.adapter.push(new class GSUIDCoreAdapter {
 | 
			
		|||
    const msgs = []
 | 
			
		||||
    for (let i of msg) {
 | 
			
		||||
      if (typeof i != "object")
 | 
			
		||||
        i = { type: "text", data: { text: i }}
 | 
			
		||||
      else if (!i.data)
 | 
			
		||||
        i = { type: i.type, data: { ...i, type: undefined }}
 | 
			
		||||
        i = { type: "text", text: i }
 | 
			
		||||
 | 
			
		||||
      switch (i.type) {
 | 
			
		||||
        case "text":
 | 
			
		||||
          i.data = i.data.text
 | 
			
		||||
          i.data = i.text
 | 
			
		||||
          break
 | 
			
		||||
        case "image":
 | 
			
		||||
          i.data = i.data.file
 | 
			
		||||
          i.data = i.file
 | 
			
		||||
          break
 | 
			
		||||
        case "record":
 | 
			
		||||
          i = { type: "file", data: i.data.file }
 | 
			
		||||
          i = { type: "file", data: i.file }
 | 
			
		||||
          break
 | 
			
		||||
        case "video":
 | 
			
		||||
          i = { type: "file", data: i.data.file }
 | 
			
		||||
          i = { type: "file", data: i.file }
 | 
			
		||||
          break
 | 
			
		||||
        case "file":
 | 
			
		||||
          i.data = i.data.file
 | 
			
		||||
          i.data = i.file
 | 
			
		||||
          break
 | 
			
		||||
        case "at":
 | 
			
		||||
          i.data = i.data.qq
 | 
			
		||||
          i.data = i.qq
 | 
			
		||||
          break
 | 
			
		||||
        case "reply":
 | 
			
		||||
          i.data = i.data.id
 | 
			
		||||
          i.data = i.id
 | 
			
		||||
          break
 | 
			
		||||
        case "node": {
 | 
			
		||||
          const array = []
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,11 @@
 | 
			
		|||
import plugin from '../../lib/plugins/plugin.js'
 | 
			
		||||
import common from '../../lib/common/common.js'
 | 
			
		||||
import fs from 'node:fs'
 | 
			
		||||
import lodash from 'lodash'
 | 
			
		||||
import moment from 'moment'
 | 
			
		||||
 | 
			
		||||
export class sendLog extends plugin {
 | 
			
		||||
  constructor () {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    super({
 | 
			
		||||
      name: '发送日志',
 | 
			
		||||
      dsc: '发送最近100条运行日志',
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +26,7 @@ export class sendLog extends plugin {
 | 
			
		|||
    this.errFile = './logs/error.log'
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async sendLog () {
 | 
			
		||||
  async sendLog() {
 | 
			
		||||
    let lineNum = this.e.msg.match(/\d+/g)
 | 
			
		||||
    if (lineNum) {
 | 
			
		||||
      this.lineNum = lineNum[0]
 | 
			
		||||
| 
						 | 
				
			
			@ -49,12 +50,12 @@ export class sendLog extends plugin {
 | 
			
		|||
      return
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let forwardMsg = await this.makeForwardMsg(`最近${log.length}条${type}日志`, log)
 | 
			
		||||
    let forwardMsg = await common.makeForwardMsg(this.e, log, `最近${log.length}条${type}日志`)
 | 
			
		||||
 | 
			
		||||
    await this.reply(forwardMsg)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getLog (logFile) {
 | 
			
		||||
  getLog(logFile) {
 | 
			
		||||
    let log = fs.readFileSync(logFile, { encoding: 'utf-8' })
 | 
			
		||||
    log = log.split('\n')
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -78,22 +79,4 @@ export class sendLog extends plugin {
 | 
			
		|||
 | 
			
		||||
    return tmp
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async makeForwardMsg (title, msg) {
 | 
			
		||||
    let forwardMsg = [{ message: title }, { message: msg }]
 | 
			
		||||
 | 
			
		||||
    /** 制作转发内容 */
 | 
			
		||||
    if (this.e.group)
 | 
			
		||||
      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
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ const { exec, execSync } = require('child_process')
 | 
			
		|||
let uping = false
 | 
			
		||||
 | 
			
		||||
export class update extends plugin {
 | 
			
		||||
  constructor () {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    super({
 | 
			
		||||
      name: '更新',
 | 
			
		||||
      dsc: '#更新 #强制更新',
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ export class update extends plugin {
 | 
			
		|||
          fnc: 'update'
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          reg: '^#全部更新$',
 | 
			
		||||
          reg: '^#全部(强制)?更新$',
 | 
			
		||||
          fnc: 'updateAll',
 | 
			
		||||
          permission: 'master'
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ export class update extends plugin {
 | 
			
		|||
    this.typeName = 'TRSS-Yunzai'
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async update () {
 | 
			
		||||
  async update() {
 | 
			
		||||
    if (!this.e.isMaster) return false
 | 
			
		||||
    if (uping) {
 | 
			
		||||
      await this.reply('已有命令更新中..请勿重复操作')
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ export class update extends plugin {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async checkGit () {
 | 
			
		||||
  async checkGit() {
 | 
			
		||||
    let ret = await execSync('git --version', { encoding: 'utf-8' })
 | 
			
		||||
    if (!ret || !ret.includes('git version')) {
 | 
			
		||||
      await this.reply('请先安装git')
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ export class update extends plugin {
 | 
			
		|||
    return true
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getPlugin (plugin = '') {
 | 
			
		||||
  getPlugin(plugin = '') {
 | 
			
		||||
    if (!plugin) {
 | 
			
		||||
      plugin = this.e.msg.replace(/#|更新|强制/g, '')
 | 
			
		||||
      if (!plugin) return ''
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +86,7 @@ export class update extends plugin {
 | 
			
		|||
    return plugin
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async execSync (cmd) {
 | 
			
		||||
  async execSync(cmd) {
 | 
			
		||||
    return new Promise((resolve, reject) => {
 | 
			
		||||
      exec(cmd, { windowsHide: true }, (error, stdout, stderr) => {
 | 
			
		||||
        resolve({ error, stdout, stderr })
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +94,7 @@ export class update extends plugin {
 | 
			
		|||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async runUpdate (plugin = '') {
 | 
			
		||||
  async runUpdate(plugin = '') {
 | 
			
		||||
    this.isNowUp = false
 | 
			
		||||
 | 
			
		||||
    let cm = 'git pull --no-rebase'
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ export class update extends plugin {
 | 
			
		|||
    return true
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getcommitId (plugin = '') {
 | 
			
		||||
  async getcommitId(plugin = '') {
 | 
			
		||||
    let cm = 'git rev-parse --short HEAD'
 | 
			
		||||
    if (plugin) {
 | 
			
		||||
      cm = `cd "plugins/${plugin}" && git rev-parse --short HEAD`
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +155,7 @@ export class update extends plugin {
 | 
			
		|||
    return commitId
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getTime (plugin = '') {
 | 
			
		||||
  async getTime(plugin = '') {
 | 
			
		||||
    let cm = 'git log -1 --pretty=format:"%cd" --date=format:"%F %T"'
 | 
			
		||||
    if (plugin) {
 | 
			
		||||
      cm = `cd "plugins/${plugin}" && git log -1 --pretty=format:"%cd" --date=format:"%F %T"`
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +173,7 @@ export class update extends plugin {
 | 
			
		|||
    return time
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async gitErr (err, stdout) {
 | 
			
		||||
  async gitErr(err, stdout) {
 | 
			
		||||
    let msg = '更新失败!'
 | 
			
		||||
    let errMsg = err.toString()
 | 
			
		||||
    stdout = stdout.toString()
 | 
			
		||||
| 
						 | 
				
			
			@ -203,7 +203,7 @@ export class update extends plugin {
 | 
			
		|||
    await this.reply([errMsg, stdout])
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async updateAll () {
 | 
			
		||||
  async updateAll() {
 | 
			
		||||
    let dirs = fs.readdirSync('./plugins/')
 | 
			
		||||
 | 
			
		||||
    await this.runUpdate()
 | 
			
		||||
| 
						 | 
				
			
			@ -221,11 +221,11 @@ export class update extends plugin {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  restart () {
 | 
			
		||||
  restart() {
 | 
			
		||||
    new Restart(this.e).restart()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getLog (plugin = '') {
 | 
			
		||||
  async getLog(plugin = '') {
 | 
			
		||||
    let cm = 'git log -20 --pretty=format:"%h||[%cd] %s" --date=format:"%F %T"'
 | 
			
		||||
    if (plugin) {
 | 
			
		||||
      cm = `cd "plugins/${plugin}" && ${cm}`
 | 
			
		||||
| 
						 | 
				
			
			@ -257,33 +257,12 @@ export class update extends plugin {
 | 
			
		|||
 | 
			
		||||
    let end = ''
 | 
			
		||||
 | 
			
		||||
    log = await this.makeForwardMsg(`${plugin || 'TRSS-Yunzai'}更新日志,共${line}条`, log, end)
 | 
			
		||||
    log = await common.makeForwardMsg(this.e, [log, end], `${plugin || 'TRSS-Yunzai'}更新日志,共${line}条`)
 | 
			
		||||
 | 
			
		||||
    return log
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async makeForwardMsg (title, msg, end) {
 | 
			
		||||
    let forwardMsg = [{ message: title }, { message: msg }]
 | 
			
		||||
 | 
			
		||||
    if (end)
 | 
			
		||||
      forwardMsg.push({ message: end })
 | 
			
		||||
 | 
			
		||||
    /** 制作转发内容 */
 | 
			
		||||
    if (this.e.group)
 | 
			
		||||
      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
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async updateLog () {
 | 
			
		||||
  async updateLog() {
 | 
			
		||||
    let log = await this.getLog()
 | 
			
		||||
    await this.reply(log)
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
 | 
			
		||||
import cfg from '../../lib/config/config.js'
 | 
			
		||||
import plugin from '../../lib/plugins/plugin.js'
 | 
			
		||||
import common from '../../lib/common/common.js'
 | 
			
		||||
import fs from 'node:fs'
 | 
			
		||||
import lodash from 'lodash'
 | 
			
		||||
import { pipeline } from 'stream'
 | 
			
		||||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ import moment from 'moment'
 | 
			
		|||
let textArr = {}
 | 
			
		||||
 | 
			
		||||
export class add extends plugin {
 | 
			
		||||
  constructor () {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    super({
 | 
			
		||||
      name: '添加表情',
 | 
			
		||||
      dsc: '添加表情,文字等',
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ export class add extends plugin {
 | 
			
		|||
    this.isGlobal = false
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async init () {
 | 
			
		||||
  async init() {
 | 
			
		||||
    if (!fs.existsSync(this.path)) {
 | 
			
		||||
      fs.mkdirSync(this.path)
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ export class add extends plugin {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async accept () {
 | 
			
		||||
  async accept() {
 | 
			
		||||
    /** 处理消息 */
 | 
			
		||||
    if (this.e.atBot && this.e.msg && this.e?.msg.includes('添加') && !this.e?.msg.includes('#')) {
 | 
			
		||||
      this.e.msg = '#' + this.e.msg
 | 
			
		||||
| 
						 | 
				
			
			@ -61,12 +61,12 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 群号key */
 | 
			
		||||
  get grpKey () {
 | 
			
		||||
  get grpKey() {
 | 
			
		||||
    return `Yz:group_id:${this.e.user_id}`
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** #添加 */
 | 
			
		||||
  async add () {
 | 
			
		||||
  async add() {
 | 
			
		||||
    this.isGlobal = this.e?.msg.includes("全局");
 | 
			
		||||
    await this.getGroupId()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -94,8 +94,7 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 获取群号 */
 | 
			
		||||
  async getGroupId () {
 | 
			
		||||
    
 | 
			
		||||
  async getGroupId() {
 | 
			
		||||
    /** 添加全局表情,存入到机器人qq文件中 */
 | 
			
		||||
    if (this.isGlobal) {
 | 
			
		||||
      this.group_id = this.e.bot.uin;
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +117,7 @@ export class add extends plugin {
 | 
			
		|||
    return false
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  checkAuth () {
 | 
			
		||||
  checkAuth() {
 | 
			
		||||
    if (this.e.isMaster) return true
 | 
			
		||||
 | 
			
		||||
    let groupCfg = cfg.getGroup(this.e.self_id, this.group_id)
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +140,7 @@ export class add extends plugin {
 | 
			
		|||
    return true
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  checkKeyWord () {
 | 
			
		||||
  checkKeyWord() {
 | 
			
		||||
    if (this.e.img && this.e.img.length > 1) {
 | 
			
		||||
      this.e.reply('添加错误:只能发送一个表情当关键词')
 | 
			
		||||
      return false
 | 
			
		||||
| 
						 | 
				
			
			@ -164,7 +163,7 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 单独添加 */
 | 
			
		||||
  async singleAdd () {
 | 
			
		||||
  async singleAdd() {
 | 
			
		||||
    if (this.e.message.length != 2) return false
 | 
			
		||||
    let msg = lodash.keyBy(this.e.message, 'type')
 | 
			
		||||
    if (!this.e.msg || !msg.image) return false
 | 
			
		||||
| 
						 | 
				
			
			@ -187,7 +186,7 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 获取添加关键词 */
 | 
			
		||||
  getKeyWord () {
 | 
			
		||||
  getKeyWord() {
 | 
			
		||||
    this.e.isGlobal = this.e.msg.includes("全局");
 | 
			
		||||
 | 
			
		||||
    this.keyWord = this.e.raw_message.trim()
 | 
			
		||||
| 
						 | 
				
			
			@ -203,7 +202,7 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 过滤别名 */
 | 
			
		||||
  trimAlias (msg) {
 | 
			
		||||
  trimAlias(msg) {
 | 
			
		||||
    let groupCfg = cfg.getGroup(this.e.self_id, this.group_id)
 | 
			
		||||
    let alias = groupCfg.botAlias
 | 
			
		||||
    if (!Array.isArray(alias)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -219,7 +218,7 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 添加内容 */
 | 
			
		||||
  async addContext () {
 | 
			
		||||
  async addContext() {
 | 
			
		||||
    this.isGlobal = this.e.isGlobal || this.getContext()?.addContext?.isGlobal;
 | 
			
		||||
    await this.getGroupId()
 | 
			
		||||
    /** 关键词 */
 | 
			
		||||
| 
						 | 
				
			
			@ -262,7 +261,7 @@ export class add extends plugin {
 | 
			
		|||
    this.e.reply(retMsg)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  saveJson () {
 | 
			
		||||
  saveJson() {
 | 
			
		||||
    let obj = {}
 | 
			
		||||
    for (let [k, v] of textArr[this.group_id]) {
 | 
			
		||||
      obj[k] = v
 | 
			
		||||
| 
						 | 
				
			
			@ -283,7 +282,7 @@ export class add extends plugin {
 | 
			
		|||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async saveImg (url, keyWord) {
 | 
			
		||||
  async saveImg(url, keyWord) {
 | 
			
		||||
    let groupCfg = cfg.getGroup(this.e.self_id, this.group_id)
 | 
			
		||||
    let savePath = `${this.facePath}${this.group_id}/`
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -321,7 +320,7 @@ export class add extends plugin {
 | 
			
		|||
    return savePath
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async getText () {
 | 
			
		||||
  async getText() {
 | 
			
		||||
    if (!this.e.raw_message) return false
 | 
			
		||||
    
 | 
			
		||||
    this.isGlobal = false
 | 
			
		||||
| 
						 | 
				
			
			@ -389,7 +388,7 @@ export class add extends plugin {
 | 
			
		|||
    return true
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  expiredMsg (keyWord, num) {
 | 
			
		||||
  expiredMsg(keyWord, num) {
 | 
			
		||||
    logger.mark(`[发送表情]${this.e.logText} ${keyWord} 表情已过期失效`)
 | 
			
		||||
 | 
			
		||||
    let arr = textArr[this.group_id].get(keyWord)
 | 
			
		||||
| 
						 | 
				
			
			@ -405,7 +404,7 @@ export class add extends plugin {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /** 初始化已添加内容 */
 | 
			
		||||
  initTextArr () {
 | 
			
		||||
  initTextArr() {
 | 
			
		||||
    if (textArr[this.group_id]) return
 | 
			
		||||
 | 
			
		||||
    textArr[this.group_id] = new Map()
 | 
			
		||||
| 
						 | 
				
			
			@ -511,7 +510,7 @@ export class add extends plugin {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async del () {
 | 
			
		||||
  async del() {
 | 
			
		||||
    this.isGlobal = this.e?.msg.includes("全局");
 | 
			
		||||
    await this.getGroupId()
 | 
			
		||||
    if (!this.group_id) return false
 | 
			
		||||
| 
						 | 
				
			
			@ -607,7 +606,7 @@ export class add extends plugin {
 | 
			
		|||
    this.saveJson()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async list () {
 | 
			
		||||
  async list() {
 | 
			
		||||
    this.isGlobal = this.e?.msg.includes("全局");
 | 
			
		||||
 | 
			
		||||
    let page = 1
 | 
			
		||||
| 
						 | 
				
			
			@ -675,9 +674,8 @@ export class add extends plugin {
 | 
			
		|||
      num++
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let end = ''
 | 
			
		||||
    if (type == 'list' && count > 100) {
 | 
			
		||||
      end = `更多内容请翻页查看\n如:#表情列表${Number(page) + 1}`
 | 
			
		||||
      msg.push(`更多内容请翻页查看\n如:#表情列表${Number(page) + 1}`)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let title = `表情列表,第${page}页,共${count}条`
 | 
			
		||||
| 
						 | 
				
			
			@ -685,40 +683,13 @@ export class add extends plugin {
 | 
			
		|||
      title = `表情${search},${count}条`
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let forwardMsg = await this.makeForwardMsg(title, msg, end)
 | 
			
		||||
    let forwardMsg = await common.makeForwardMsg(this.e, msg, title)
 | 
			
		||||
 | 
			
		||||
    this.e.reply(forwardMsg)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async makeForwardMsg (title, msg, end = '') {
 | 
			
		||||
    let forwardMsg = [{ message: title }]
 | 
			
		||||
 | 
			
		||||
    let msgArr = lodash.chunk(msg, 40)
 | 
			
		||||
    msgArr.forEach(v => {
 | 
			
		||||
      v[v.length - 1] = lodash.trim(v[v.length - 1], '\n')
 | 
			
		||||
      forwardMsg.push({ message: v })
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    if (end)
 | 
			
		||||
      forwardMsg.push({ message: end })
 | 
			
		||||
 | 
			
		||||
    /** 制作转发内容 */
 | 
			
		||||
    if (this.e.group)
 | 
			
		||||
      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
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** 分页 */
 | 
			
		||||
  pagination (pageNo, pageSize, array) {
 | 
			
		||||
  pagination(pageNo, pageSize, array) {
 | 
			
		||||
    let offset = (pageNo - 1) * pageSize
 | 
			
		||||
    return offset + pageSize >= array.length ? array.slice(offset, array.length) : array.slice(offset, offset + pageSize)
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue