mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
适配其他uin
This commit is contained in:
parent
6e5ef2e1f5
commit
e90d6f11ca
5 changed files with 18 additions and 18 deletions
16
apps/chat.js
16
apps/chat.js
|
|
@ -25,7 +25,7 @@ import {
|
|||
getUserReplySetting,
|
||||
getImageOcrText,
|
||||
getImg,
|
||||
getMaxModelTokens, formatDate, generateAudio, formatDate2, mkdirs
|
||||
getMaxModelTokens, formatDate, generateAudio, formatDate2, mkdirs, getUin
|
||||
} from '../utils/common.js'
|
||||
import { ChatGPTPuppeteer } from '../utils/browser.js'
|
||||
import { KeyvFile } from 'keyv-file'
|
||||
|
|
@ -315,7 +315,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
let ats = e.message.filter(m => m.type === 'at')
|
||||
const isAtMode = Config.toggleMode === 'at'
|
||||
if (isAtMode) ats = ats.filter(item => item.qq !== Bot.uin)
|
||||
if (isAtMode) ats = ats.filter(item => item.qq !== getUin(e))
|
||||
if (ats.length === 0) {
|
||||
if (use === 'api3') {
|
||||
await redis.del(`CHATGPT:QQ_CONVERSATION:${(e.isGroup && Config.groupMerge) ? e.group_id.toString() : e.sender.user_id}`)
|
||||
|
|
@ -764,11 +764,11 @@ export class chatgpt extends plugin {
|
|||
if (e.isGroup && !e.atme) {
|
||||
return false
|
||||
}
|
||||
if (e.user_id == Bot.uin) return false
|
||||
if (e.user_id == getUin(e)) return false
|
||||
prompt = e.raw_message.trim()
|
||||
if (e.isGroup && typeof this.e.group.getMemberMap === 'function') {
|
||||
let mm = await this.e.group.getMemberMap()
|
||||
let me = mm.get(Bot.uin)
|
||||
let me = mm.get(getUin(e))
|
||||
let card = me.card
|
||||
let nickname = me.nickname
|
||||
if (nickname && card) {
|
||||
|
|
@ -1477,7 +1477,7 @@ export class chatgpt extends plugin {
|
|||
chatViewBotName: Config.chatViewBotName || '',
|
||||
entry: cacheData.file,
|
||||
userImg: `https://q1.qlogo.cn/g?b=qq&s=0&nk=${e.sender.user_id}`,
|
||||
botImg: `https://q1.qlogo.cn/g?b=qq&s=0&nk=${Bot.uin}`,
|
||||
botImg: `https://q1.qlogo.cn/g?b=qq&s=0&nk=${getUin(e)}`,
|
||||
cacheHost: Config.serverHost,
|
||||
qq: e.sender.user_id
|
||||
})
|
||||
|
|
@ -1586,7 +1586,7 @@ export class chatgpt extends plugin {
|
|||
opt.qq = e.sender.user_id
|
||||
opt.nickname = e.sender.card
|
||||
opt.groupName = e.group.name
|
||||
opt.botName = e.isGroup ? (e.group.pickMember(Bot.uin).card || e.group.pickMember(Bot.uin).nickname) : Bot.nickname
|
||||
opt.botName = e.isGroup ? (e.group.pickMember(getUin(e)).card || e.group.pickMember(getUin(e)).nickname) : Bot.nickname
|
||||
let master = (await getMasterQQ())[0]
|
||||
if (master && e.group) {
|
||||
opt.masterName = e.group.pickMember(parseInt(master)).card || e.group.pickMember(parseInt(master)).nickname
|
||||
|
|
@ -2019,7 +2019,7 @@ export class chatgpt extends plugin {
|
|||
opt.qq = e.sender.user_id
|
||||
opt.nickname = e.sender.card
|
||||
opt.groupName = e.group.name
|
||||
opt.botName = e.isGroup ? (e.group.pickMember(Bot.uin).card || e.group.pickMember(Bot.uin).nickname) : Bot.nickname
|
||||
opt.botName = e.isGroup ? (e.group.pickMember(getUin(e)).card || e.group.pickMember(getUin(e)).nickname) : Bot.nickname
|
||||
let master = (await getMasterQQ())[0]
|
||||
if (master && e.group) {
|
||||
opt.masterName = e.group.pickMember(parseInt(master)).card || e.group.pickMember(parseInt(master)).nickname
|
||||
|
|
@ -2191,7 +2191,7 @@ export class chatgpt extends plugin {
|
|||
logger.mark(logger.green('【ChatGPT-Plugin】插件avocado-plugin未安装') + ',安装后可查看最近热映电影与体验可玩性更高的点歌工具。\n可前往 https://github.com/Qz-Sean/avocado-plugin 获取')
|
||||
}
|
||||
if (e.isGroup) {
|
||||
let botInfo = await Bot.getGroupMemberInfo(e.group_id, Bot.uin, true)
|
||||
let botInfo = await Bot.getGroupMemberInfo(e.group_id, getUin(e), true)
|
||||
if (botInfo.role !== 'member') {
|
||||
// 管理员才给这些工具
|
||||
tools.push(...[new EditCardTool(), new JinyanTool(), new KickOutTool(), new HandleMessageMsgTool(), new SetTitleTool()])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { render } from '../utils/common.js'
|
||||
import { render, getUin } from '../utils/common.js'
|
||||
import { Config } from '../utils/config.js'
|
||||
import { KeyvFile } from 'keyv-file'
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ export class history extends plugin {
|
|||
async history (e) {
|
||||
let use = await redis.get('CHATGPT:USE') || 'api'
|
||||
let chat = []
|
||||
let filtered = e.message.filter(m => m.type === 'at').filter(m => m.qq !== Bot.uin)
|
||||
let filtered = e.message.filter(m => m.type === 'at').filter(m => m.qq !== getUin(e))
|
||||
let queryUser = e.sender.user_id
|
||||
let user = e.sender
|
||||
if (filtered.length > 0) {
|
||||
|
|
@ -99,7 +99,7 @@ export class history extends plugin {
|
|||
name: user.card || user.nickname || user.user_id
|
||||
},
|
||||
bot: {
|
||||
qq: Bot.uin,
|
||||
qq: getUin(e),
|
||||
name: Bot.nickname
|
||||
},
|
||||
chat
|
||||
|
|
|
|||
|
|
@ -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 { getMasterQQ, limitString, makeForwardMsg, maskQQ } from '../utils/common.js'
|
||||
import { getMasterQQ, limitString, makeForwardMsg, maskQQ, getUin } from '../utils/common.js'
|
||||
import { deleteOnePrompt, getPromptByName, readPrompts, saveOnePrompt } from '../utils/prompts.js'
|
||||
import AzureTTS from "../utils/tts/microsoft-azure.js";
|
||||
export class help extends plugin {
|
||||
|
|
@ -246,7 +246,7 @@ export class help extends plugin {
|
|||
async removeSharePrompt (e) {
|
||||
let master = (await getMasterQQ())[0]
|
||||
let name = e.msg.replace(/^#(chatgpt|ChatGPT)(删除|取消|撤销)共享设定/, '')
|
||||
let response = await fetch(`https://chatgpt.roki.best/prompt?name=${name}&qq=${master || (Bot.uin + '')}`, {
|
||||
let response = await fetch(`https://chatgpt.roki.best/prompt?name=${name}&qq=${master || (getUin(e) + '')}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'FROM-CHATGPT': 'ikechan8370'
|
||||
|
|
@ -354,7 +354,7 @@ export class help extends plugin {
|
|||
let toUploadBody = {
|
||||
title: currentUse,
|
||||
prompt: content,
|
||||
qq: master || (Bot.uin + ''), // 上传者设定为主人qq或机器人qq
|
||||
qq: master || (getUin(this.e) + ''), // 上传者设定为主人qq或机器人qq
|
||||
use: extraData.use === 'Custom' ? 'Sydney' : 'ChatGPT',
|
||||
r18,
|
||||
description
|
||||
|
|
|
|||
|
|
@ -84,14 +84,14 @@ export async function makeForwardMsg (e, msg = [], dec = '') {
|
|||
let nickname = Bot.nickname
|
||||
if (e.isGroup) {
|
||||
try {
|
||||
let info = await Bot.getGroupMemberInfo(e.group_id, Bot.uin)
|
||||
let info = await Bot.getGroupMemberInfo(e.group_id, getUin(e))
|
||||
nickname = info.card || info.nickname
|
||||
} catch (err) {
|
||||
console.error(`Failed to get group member info: ${err}`)
|
||||
}
|
||||
}
|
||||
let userInfo = {
|
||||
user_id: Bot.uin,
|
||||
user_id: getUin(e),
|
||||
nickname
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import crypto from 'crypto'
|
|||
import child_process from 'child_process'
|
||||
import { Config } from './config.js'
|
||||
import path from 'path'
|
||||
import { mkdirs } from './common.js'
|
||||
import { mkdirs, getUin } from './common.js'
|
||||
let module
|
||||
try {
|
||||
module = await import('oicq')
|
||||
|
|
@ -139,7 +139,7 @@ async function uploadRecord (recordUrl, ttsMode = 'vits-uma-genshin-honkai') {
|
|||
2: 3,
|
||||
5: {
|
||||
1: Contactable.target,
|
||||
2: Bot.uin,
|
||||
2: getUin(e),
|
||||
3: 0,
|
||||
4: hash,
|
||||
5: buf.length,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue