mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 过长消息(多于4000)被slack夹断切分的问题
This commit is contained in:
parent
fd06f8c21a
commit
40b72989e4
3 changed files with 12 additions and 2 deletions
|
|
@ -1514,6 +1514,7 @@ export class chatgpt extends plugin {
|
||||||
logger.info('开启Claude新对话,但旧对话未结束,自动结束上一次对话')
|
logger.info('开启Claude新对话,但旧对话未结束,自动结束上一次对话')
|
||||||
await redis.del(`CHATGPT:SLACK_CONVERSATION:${e.sender.user_id}`)
|
await redis.del(`CHATGPT:SLACK_CONVERSATION:${e.sender.user_id}`)
|
||||||
}
|
}
|
||||||
|
logger.info('send preset: ' + preset.content)
|
||||||
response = await client.sendMessage(preset.content, e)
|
response = await client.sendMessage(preset.content, e)
|
||||||
await e.reply(response, true)
|
await e.reply(response, true)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -422,11 +422,15 @@ export async function isCN () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function limitString (str, maxLength) {
|
export function limitString (str, maxLength, addDots = true) {
|
||||||
if (str.length <= maxLength) {
|
if (str.length <= maxLength) {
|
||||||
return str
|
return str
|
||||||
} else {
|
} else {
|
||||||
return str.slice(0, maxLength) + '...'
|
if (addDots) {
|
||||||
|
return str.slice(0, maxLength) + '...'
|
||||||
|
} else {
|
||||||
|
return str.slice(0, maxLength)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Config } from '../config.js'
|
import { Config } from '../config.js'
|
||||||
import slack from '@slack/bolt'
|
import slack from '@slack/bolt'
|
||||||
import delay from 'delay'
|
import delay from 'delay'
|
||||||
|
import {limitString} from "../common.js";
|
||||||
let proxy
|
let proxy
|
||||||
if (Config.proxy) {
|
if (Config.proxy) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -33,6 +34,10 @@ export class SlackClaudeClient {
|
||||||
if (t > 10) {
|
if (t > 10) {
|
||||||
return 'claude 未响应'
|
return 'claude 未响应'
|
||||||
}
|
}
|
||||||
|
if (prompt.length > 3990) {
|
||||||
|
logger.warn('消息长度大于slack限制,长度剪切至3990')
|
||||||
|
prompt = limitString(prompt, 3990, false)
|
||||||
|
}
|
||||||
let qq = e.sender.user_id
|
let qq = e.sender.user_id
|
||||||
let channels = await this.app.client.conversations.list({
|
let channels = await this.app.client.conversations.list({
|
||||||
token: this.config.slackUserToken,
|
token: this.config.slackUserToken,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue