mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
fix: #613
This commit is contained in:
parent
46d88c2669
commit
1c6c10b118
3 changed files with 75 additions and 68 deletions
|
|
@ -12,6 +12,7 @@ import { translate, translateLangSupports } from '../utils/translate.js'
|
||||||
import AzureTTS from '../utils/tts/microsoft-azure.js'
|
import AzureTTS from '../utils/tts/microsoft-azure.js'
|
||||||
import VoiceVoxTTS from '../utils/tts/voicevox.js'
|
import VoiceVoxTTS from '../utils/tts/voicevox.js'
|
||||||
import { URL } from 'node:url'
|
import { URL } from 'node:url'
|
||||||
|
import { getBots } from '../utils/bot.js'
|
||||||
|
|
||||||
let useSilk = false
|
let useSilk = false
|
||||||
try {
|
try {
|
||||||
|
|
@ -350,7 +351,7 @@ ${translateLangLabels}
|
||||||
let groupId = e.msg.replace(/^#chatgpt打招呼/, '')
|
let groupId = e.msg.replace(/^#chatgpt打招呼/, '')
|
||||||
logger.info(groupId)
|
logger.info(groupId)
|
||||||
groupId = parseInt(groupId)
|
groupId = parseInt(groupId)
|
||||||
if (groupId && !e.bot.getGroupList().get(groupId)) {
|
if (groupId && !e.bot.gl.get(groupId)) {
|
||||||
await e.reply('机器人不在这个群里!')
|
await e.reply('机器人不在这个群里!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +380,9 @@ ${translateLangLabels}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
let groupId = parseInt(element)
|
let groupId = parseInt(element)
|
||||||
if (this.e.bot.getGroupList().get(groupId)) {
|
let bots = this.e ? [this.e.bot] : getBots()
|
||||||
|
for (let bot of bots) {
|
||||||
|
if (bot.gl?.get(groupId)) {
|
||||||
// 打招呼概率
|
// 打招呼概率
|
||||||
if (Math.floor(Math.random() * 100) < Config.helloProbability) {
|
if (Math.floor(Math.random() * 100) < Config.helloProbability) {
|
||||||
let message = await generateHello()
|
let message = await generateHello()
|
||||||
|
|
@ -450,6 +453,7 @@ ${translateLangLabels}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async handleSentMessage (e) {
|
async handleSentMessage (e) {
|
||||||
const addReg = /^#chatgpt设置打招呼[::]?\s?(\S+)(?:\s+(\d+))?(?:\s+(\d+))?$/
|
const addReg = /^#chatgpt设置打招呼[::]?\s?(\S+)(?:\s+(\d+))?(?:\s+(\d+))?$/
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,8 @@
|
||||||
import { UserInfo, AddUser } from './user_data.js'
|
import { UserInfo, AddUser } from './user_data.js'
|
||||||
import { randomString, getUserData, getMasterQQ, getUin } from '../../utils/common.js'
|
import { randomString, getUserData, getMasterQQ, getUin } from '../../utils/common.js'
|
||||||
|
import { getBots } from '../../utils/bot.js';
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import path from 'path';
|
||||||
function getBots () {
|
|
||||||
if (Bot.uin === 88888) {
|
|
||||||
// 找适配器
|
|
||||||
let adapters = Bot.adapter
|
|
||||||
return adapters?.map(uin => Bot[uin])
|
|
||||||
} else if (Bot.adapter && Bot.adapter.length > 0) {
|
|
||||||
let bots = [Bot]
|
|
||||||
Bot.adapter.forEach(uin => {
|
|
||||||
bots.push(Bot[uin])
|
|
||||||
})
|
|
||||||
return bots
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function User (fastify, options) {
|
async function User (fastify, options) {
|
||||||
// 登录
|
// 登录
|
||||||
|
|
|
||||||
15
utils/bot.js
Normal file
15
utils/bot.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
export function getBots () {
|
||||||
|
if (Bot.uin === 88888) {
|
||||||
|
// 找适配器
|
||||||
|
let adapters = Bot.adapter
|
||||||
|
return adapters?.map(uin => Bot[uin])
|
||||||
|
} else if (Bot.adapter && Bot.adapter.length > 0) {
|
||||||
|
let bots = [Bot]
|
||||||
|
Bot.adapter.forEach(uin => {
|
||||||
|
bots.push(Bot[uin])
|
||||||
|
})
|
||||||
|
return bots
|
||||||
|
} else {
|
||||||
|
return [Bot]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue