mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 修复多token功能带来的一些影响
This commit is contained in:
parent
e93614ca35
commit
fd408586a8
2 changed files with 32 additions and 13 deletions
|
|
@ -3,7 +3,7 @@ import { Config } from '../utils/config.js'
|
|||
import { BingAIClient } from '@waylaidwanderer/chatgpt-api'
|
||||
import { exec } from 'child_process'
|
||||
import { checkPnpm, formatDuration, parseDuration } from '../utils/common.js'
|
||||
import SydneyAIClient from "../utils/SydneyAIClient.js";
|
||||
import SydneyAIClient from '../utils/SydneyAIClient.js'
|
||||
|
||||
export class ChatgptManagement extends plugin {
|
||||
constructor (e) {
|
||||
|
|
@ -168,7 +168,7 @@ export class ChatgptManagement extends plugin {
|
|||
await this.reply(`${tokens}`, true)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
async delBingAccessToken (e) {
|
||||
this.setContext('deleteBingToken')
|
||||
let tokens = await redis.get('CHATGPT:BING_TOKEN')
|
||||
|
|
@ -211,7 +211,7 @@ export class ChatgptManagement extends plugin {
|
|||
let bingToken = await redis.get('CHATGPT:BING_TOKEN')
|
||||
bingToken = bingToken.split('|')
|
||||
if (!bingToken.includes(token)) bingToken.push(token)
|
||||
bingToken = bingToken.filter (function (element) { return element !== '' })
|
||||
bingToken = bingToken.filter(function (element) { return element !== '' })
|
||||
token = bingToken.join('|')
|
||||
}
|
||||
await redis.set('CHATGPT:BING_TOKEN', token)
|
||||
|
|
@ -224,14 +224,14 @@ export class ChatgptManagement extends plugin {
|
|||
let bingToken = await redis.get('CHATGPT:BING_TOKEN')
|
||||
bingToken = bingToken.split('|')
|
||||
let tokenId = this.e.msg
|
||||
if (!bingToken[tokenId]) {
|
||||
if (bingToken[tokenId] === null || bingToken[tokenId] === undefined) {
|
||||
await this.reply('Token编号错误!', true)
|
||||
this.finish('deleteBingToken')
|
||||
return
|
||||
}
|
||||
const removeToken = bingToken[tokenId]
|
||||
bingToken.splice(tokenId, 1)
|
||||
bingToken = bingToken.filter (function (element) { return element !== '' })
|
||||
bingToken = bingToken.filter(function (element) { return element !== '' })
|
||||
let token = bingToken.join('|')
|
||||
await redis.set('CHATGPT:BING_TOKEN', token)
|
||||
await this.reply(`Token ${removeToken.substring(0, 5 / 2) + '...' + removeToken.substring(removeToken.length - 5 / 2, removeToken.length)} 移除成功`, true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue