Merge branch 'ikechan8370:v2' into v2

This commit is contained in:
ifeif 2023-12-03 20:38:10 +08:00 committed by GitHub
commit 4a6cad2e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 71 deletions

View file

@ -803,7 +803,7 @@ export class chatgpt extends plugin {
if (!msg || e.msg?.startsWith('#')) {
return false
}
if ((e.isGroup || e.group_id) && !(e.atme || e.atBot)) {
if ((e.isGroup || e.group_id) && !(e.atme || e.atBot || (e.at === e.self_id))) {
return false
}
if (e.user_id == getUin(e)) return false
@ -1639,7 +1639,7 @@ export class chatgpt extends plugin {
opt.groupId = e.group_id
opt.qq = e.sender.user_id
opt.nickname = e.sender.card
opt.groupName = e.group.name
opt.groupName = e.group.name || e.group_name
opt.botName = e.isGroup ? (e.group.pickMember(getUin(e)).card || e.group.pickMember(getUin(e)).nickname) : e.bot.nickname
let master = (await getMasterQQ())[0]
if (master && e.group) {

View file

@ -12,6 +12,7 @@ import { translate, translateLangSupports } from '../utils/translate.js'
import AzureTTS from '../utils/tts/microsoft-azure.js'
import VoiceVoxTTS from '../utils/tts/voicevox.js'
import { URL } from 'node:url'
import { getBots } from '../utils/bot.js'
let useSilk = false
try {
@ -350,7 +351,7 @@ ${translateLangLabels}
let groupId = e.msg.replace(/^#chatgpt打招呼/, '')
logger.info(groupId)
groupId = parseInt(groupId)
if (groupId && !e.bot.getGroupList().get(groupId)) {
if (groupId && !e.bot.gl.get(groupId)) {
await e.reply('机器人不在这个群里!')
return
}
@ -379,7 +380,9 @@ ${translateLangLabels}
continue
}
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) {
let message = await generateHello()
@ -450,6 +453,7 @@ ${translateLangLabels}
}
}
}
}
async handleSentMessage (e) {
const addReg = /^#chatgpt设置打招呼[:]?\s?(\S+)(?:\s+(\d+))?(?:\s+(\d+))?$/

View file

@ -1,20 +1,8 @@
import { UserInfo, AddUser } from './user_data.js'
import { randomString, getUserData, getMasterQQ, getUin } from '../../utils/common.js'
import { getBots } from '../../utils/bot.js';
import fs from 'fs'
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
}
}
import path from 'path';
async function User (fastify, options) {
// 登录

15
utils/bot.js Normal file
View 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]
}
}

View file

@ -136,7 +136,7 @@ export class ClaudeAIClient {
attachments,
completion: {
incremental: true,
model: 'claude-2',
model: 'claude-2.1',
prompt: text,
timezone: 'Asia/Hong_Kong'
}

View file

@ -848,6 +848,7 @@ export function getMaxModelTokens (model = 'gpt-3.5-turbo') {
}
export function getUin (e) {
if (e?.self_id) return e.self_id
if (e?.bot?.uin) return e.bot.uin
if (Array.isArray(Bot.uin)) {
if (Config.trssBotUin && Bot.uin.indexOf(Config.trssBotUin) > -1) { return Config.trssBotUin } else {