fix: 修复过长设定发不出来的。后续用图片

This commit is contained in:
ikechan8370 2023-03-14 20:36:05 +08:00
parent c781df07a1
commit 83c789baf4
3 changed files with 13 additions and 4 deletions

View file

@ -2,7 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js'
import fs from 'fs'
import _ from 'lodash'
import { Config } from '../utils/config.js'
import { makeForwardMsg } from '../utils/common.js'
import {limitString, makeForwardMsg} from '../utils/common.js'
import { getPromptByName, readPrompts, saveOnePrompt } from '../utils/prompts.js'
export class help extends plugin {
constructor (e) {
@ -63,7 +63,8 @@ export class help extends plugin {
}
prompts.push(...[defaultPrompt, defaultSydneyPrompt])
prompts.push(...readPrompts())
e.reply(await makeForwardMsg(e, prompts.map(p => `${p.name}\n${p.content}`), '设定列表'))
console.log(prompts)
e.reply(await makeForwardMsg(e, prompts.map(p => `${p.name}\n${limitString(p.content, 500)}`), '设定列表'))
}
async detailPrompt (e) {
@ -85,7 +86,7 @@ export class help extends plugin {
return
}
}
await e.reply(`${prompt.name}\n${prompt.content}`, true)
await e.reply(`${prompt.name}\n${limitString(p.content, 500)}`, true)
}
async usePrompt (e) {

View file

@ -374,3 +374,11 @@ export async function isCN () {
}
}
}
export function limitString(str, maxLength) {
if (str.length <= maxLength) {
return str;
} else {
return str.slice(0, maxLength) + '...';
}
}

View file

@ -1,6 +1,6 @@
import _ from 'lodash'
import fs from 'fs'
import {mkdirs} from "./common.js";
import { mkdirs } from './common.js'
export function readPrompts () {
const _path = process.cwd()
let prompts = []